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 app challenge 🔥

Jose Jimmy• 290

@jose-jimmy

Desktop design screenshot for the Age calculator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hi everyone👋, Finally completed the Age Calculator App challenge

I thought this will be a pretty easy challenge but it took me a while to figure out the solution, I have only tested the system manually so the chances for typos are more, if you find something do let me know.

I know this is not an optimal solution and there are always room for improvements if you have any suggestions please free to comment below. Open to any feedbacks.

This is the basic logic behind calculating the age and I found out this the easiest and most optimal way.

Happy coding! 😃

const date = new Date(0);
const currentDay = date.getUTCDate();
const currentMonth = date.getUTCMonth();
const currentYear = date.getUTCFullYear();

const birthDate = new Date(`${userYear}-${userMonth}-${userDay}`);
const diff = new Date(Date.now() - birthDate.getTime());

resultingYear = Math.abs(diff.getUTCFullYear() - currentYear);
resultingMonth = Math.abs(diff.getUTCMonth() - currentMonth);
resultingDay = Math.abs(diff.getUTCDate() - currentDay);

Community feedback

Aimal Khan• 2,260

@Aimal-125

Posted

In your CSS code, give body element height of 120 or 150vh by using media query with max-height: 400px; so that your solution looks good on screens with small heights.

0

Jose Jimmy• 290

@jose-jimmy

Posted

@Aimal-125 Thanks for checking out the solution, I think this is not necessary as most mobile devices have height more than 500px and the solution works pretty good with those heights.

2

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