Design comparison
Community feedback
- @fibonacci001Posted over 1 year ago
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; // ... }
2
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord