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 calculation app using html/css and javascript

Nd-praise 70

@Nd-praise

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

r3cla 40

@r3cla

Posted

Hi. Great work!

I just finished this challenge myself, so thought I could give you a couple tips that I found were super helpful for me.

1- Remove incremental arrows from the input boxes. If you want to get rid of them, you can use appearance: textfield; in your CSS file. Example:

    width: 70px;
    padding: 10%;
    border-radius: 5px;
    border: 2px solid var(--color-Off-white);
    outline: none;
    font-family: popins;
    appearance: textfield;

If for some reason the above does not work for, you can target specific browsers with -webkit-appearance: (chrome/safari) and -moz-appearance: (firefox).

2- Your age calculation appears to be off slightly

My understanding is the Date object in Javascript does not always accurately calculate full birth dates like this due to leap years. I am not 100% certain this is the issue in your case, but after a brief glimpse I believe it could be true.

To remedy the issue with leap years in age calculation, the key is to accurately calculate the difference in days, months, and years separately. Specifically, when the calculated days are negative, it's important to adjust by subtracting one month and adding the number of days from the previous month to the day count. This method inherently accounts for the extra day in February during leap years, as the Date object in JavaScript correctly handles the leap year by returning 29 days for February when applicable. By doing this, the age calculation (HOPEFULLY) remains accurate.

I came to this conclusion by entering my own birthdate: 10/05/1991, which should return 32 Years, 9 Months, 9 Days but came back with 32y, 4m, 5d.

I am not a code wizard like others on this site but I hope this can be of some help to you. Otherwise, you've done a great job.

Cheers :D

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