Skip to content
Submitted almost 3 years ago

Age Calculator

LVL 2
@tomhill10
A solution to the Age calculator app challenge

Solution retrospective


Frontend Mentor - Age calculator app - HTML CSS JAVASCRIPT

First time building an app with Javascript Trying to break down what I need to achieve with Javascript. I have three data inputs.

I need to validate the data so that the dates and years match etc. Set max values so people can't be > current date Take values from inputs and take them from the current date to get an output. Age of person = current date - birth date

had a look at the date or new date() constructor. Might be able to parse in the values from the inputs to create a date then - that from current date!

Stuff I learned:

Put Javascript at the bottom of the page!!!! Managed to get an event listender to work. Have to make sure that I am not calling a function inside of itself. i.e. Don't write the function out in full inside of the event listener!!! DUR! I think I have managed to make the month check if the correct amount of days in said month. With the .getDate() object. or new Date. Read an article and here we are. tried calculating the difference in years/months/days without using JS methods. It didn't go well. Using methods seemed to work better. Still wrapping head around the date object. My button.addEventListener is looking huge. Maybe there is a way to split this up?

Code
Loading...

Please log in to post a comment

Log in

Community feedback

No feedback yet. Be the first to give feedback on tomhill10’s solution.

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