Age calculator with CSS HTML and Javascript

Solution retrospective
I think the javascript part could be done in a more simple way.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @tinuola
@Erick, Good job with the functionality.
A recommendation to make the JavaScript simpler (or more functional) is to consider breaking up the three logical checks/operations into separate functions that are then called by the event listener. Currently, all that logic inside the event listener can be confusing to read.
Also, the logic used to validate the required inputs (day, month, year) is the same; therefore it can be refactored into a single function. Consider giving the inputs a shared class and use a forEach loop to add an event listener that calls the function when the fields get a value.
You might be able to use a similar approach with other areas of the code that are running repetitive logic.
Marked as helpful
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