@fibonacci001
Posted
hi Austine, your code is well-formatted and easy to read. Good job on using consistent indentation, spacing, and naming conventions.👍
The isValidEmailFormat function is simple and clear, but it has a redundant check for the email address. The emailRegex.test(emailAddress) method will return false if the emailAddress is an empty string, so there is no need to add the Boolean(emailAddress) check. You can simplify the function to:
function isValidEmailFormat(emailAddress) { return emailRegex.test(emailAddress); }
You are also using the document.getElementById method multiple times to access the same elements. This is inefficient and repetitive. You could just store the elements in variables outside the function and reuse them inside the function. just like this:
const errorDisplay = document.getElementById("error-display");
const successDisplay = document.getElementById("success-display");
const errorIcon = document.getElementById("error-icon");
function signUp() {
// use the variables instead of calling document.getElementById again
const email = emailInput.value;
// ...
}