Design comparison
Solution retrospective
I'm still fairly new to coding and I would like some criticism on how to improve my code specially JS so I can ultimately become a better coder..
Community feedback
- @mattstuddertPosted over 4 years ago
Hey Aayushi, nice work on this challenge! My main recommendation for how you could improve your JS code would be to reduce code duplication.
You'll notice that all of your conditional statements that are checking for empty fields are identical. To reduce this code you could have a single statement inside a loop to check all
input
elements one after another.This would mean making your selector more general (
const inputs = document.querySelector('input')
) and then looping through those elements and checking the value on each iteration.Have a go at this and see how you get on. As developers, we try to keep our code D.R.Y. (Don't Repeat Yourself), which keeps our code more maintainable. If you ever find yourself writing the same code multiple times, this code would be a perfect candidate to be DRYed up.
I'd also recommend having a go at resolving the accessibility errors.
I hope this helps. Keep up the great work! 👍
1@iucsimPosted over 4 years ago@mattstuddert I have changed JS as per your instructions.
I think now it's look satisfactory.
Thanks for the feedback:)
0@mattstuddertPosted over 4 years ago@iucsim much better, nice work! Now just to clear the accessibility errors 😉
0
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