Design comparison
Solution retrospective
I'm always looking for more feedback and having someone else look at my work would be helpful to learning more.
I feel like my js is pretty messy, so I feel like I could improve on that.
Community feedback
- @akpekigPosted over 1 year ago
To improve your Javascript, give elements a unifying class, i.e. "dateInput" and use
document.querySelectorAll()
with a loop. That way, instead of writing the same conditional three times with a different variable, you can just write it once.To reduce the size of your conditionals, you can write arrays or objects for the months with a specific number of days to validate against or convert input values to strings and use regular experessions.
Marked as helpful1@treaty1210Posted over 1 year ago@akpekig Oh, I see. I'll give that a shot. I'm still not that comfortable with loops yet, but if it can help improve my work I'm always willing to try it out.
Thank you! It never crossed my mind to use arrays or objects for the months.
Thank you for your feedback. It's been very helpful.
1
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