Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

ping-coming-soons / html, css, javascript

@EAguayodev

Desktop design screenshot for the Ping single column coming soon page coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Would like feedback on whether the javascript written was good code or couldve been written better.

Community feedback

@tomthestrom

Posted

Hey Eric, it's easy to read, I see what it means to do, good job on that. Since you asked for feedback, I have a few things to say.

Did you test it? You're using a validEmail() function that is not defined.

Everything is in global namespace, which for this app with a few lines is alright, but you could solve it with an IIFE.

isvalidateEmail is not camelCase and sounds like it does 2 things, while it only does one. I would call it isValidEmail since it returns true or false based on a regex.

You could extract the part where you do:

      email.classList.add('error');
      email.innerText = 'Email cannot be blank';

      email.classList.add('error');
      email.innerText = 'Email is invalid!';

into a function. You could have a place to store these error messages, and then just pass the error message to email.innerText based on the given parameter.

const small = form.querySelector('small'); this way of selecting an element is error prone, you should either use an id or a data attribute. You need to be able to always uniquely identify the element you wanna manipulate. Imagine you'd have another <small> element in the form, this code could break.

Also for the github repo, you should not be having a directory and nothing else at the root level. You should move the contents of that directory into root. While at it, I would include a .gitignore and a README.md file.

Have a good day,

Tom

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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