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
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Age Calculator

@mmaazkhanhere

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

@mmaazkhanhere

Posted

It would be really helpful if someone can help me how to calculate age correctly including leap years and 30 31 day variations. I tried but couldnt get it correctly

0

Adrian 200

@Hoodie1309

Posted

@mmaazkhanhere Hello. My solution for this problem:

const date = new Date(); const actualYear = date.getFullYear(); const actualMonth = date.getMonth() + 1;

const getDays = (year, month) => { return new Date(year, month, 0).getDate() }

const days = getDays(actualYear, actualMonth);

const days will return 30 or 31 and this const days you must use in your conditional if statement.

if it is not clear write and I will try to explain :)

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