Not Found
Not Found
Not Found
Not Found
Not Found
Request path contains unescaped characters
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

HTML, CSS, JAVASCRIPT

@Mastermind390

Desktop design screenshot for the Age calculator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Community feedback

@arturasmckwcz

Posted

Hey Enitan,

Thanks for reviewing my Age calculator app. I noticed that you calculated the age in years, months, and days between dates, which is a better approach than converting milliseconds. However, I found that your code doesn't produce 100% accurate results. I suggest leveraging JavaScript's Date object to handle leap years, the number of days in months, and other factors for more accurate calculations. Wish you the best!

Marked as helpful

0

@Mastermind390

Posted

@arturasmckwcz Thanks for your observation and suggestion.

what you just pointed out came across my mind when I was working on the project but I don't know how to go about it. I will appreciate if you can help me with how to achieve that.

Thanks so much.

0

@arturasmckwcz

Posted

@Mastermind390

The first of all I'd consider the quite obvious rule: if dates differs by years only, then months and days should be 0s, for example 10 years 0 month 0 days are between 09.09.2013 and 09.09.2023 right? Regarding leveraging Date object I'd use constructor Date(year, month, day) where args are of number type and month number is 0 based. It already takes care of a number of days in a month and if a year is leap. For example new Date(2023,1,29) will return 2023-03-01, so I used that to check if a date is correct by new Date(year, month-1, day).getDate() === day, etc.

Marked as helpful

0

@Mastermind390

Posted

@arturasmckwcz thanks for this I will check it out.

0

@arturasmckwcz

Posted

@Mastermind390

you're welcome! now it does calc much better, however I figured that for dates from the next day year ago like 22.09.2022 (today 21.09.2023) to the end of that year (2022) it prints all zeros, which isn't correct

0

Please log in to post a comment

Log in with GitHub
Discord logo

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