Age Calculator App Main (HTML, CSS/SCS, JAVASCRIPT, RESPONSIVE)
Design comparison
Solution retrospective
The validate() function is used to validate the input fields and ensure that they contain valid values. The function loops through all input fields and checks if they are empty. If an input is empty, it sets its border color to red, displays an error message, and sets the validator to false. If all inputs are valid, the function returns true.
The animateNumber() function is used to animate numbers. It takes in three arguments - the target number, the HTML element that will display the number, and a delay. It uses setInterval() to increment the displayed number gradually until it reaches the target number.
The handleSubmit() function is called when the user clicks the submit button. It first calls the validate() function to ensure that the inputs are valid. If they are, it calculates the age by subtracting the input birthdate from the current date, taking into account the number of days in each month. Finally, it calls the animateNumber() function for each output element to display the calculated age.
Community feedback
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