Age Calculator Application (Sass + JavaScript)

Solution retrospective
Hello everyone, here's my solution for this challenge. I had a lot of fun building it and starting to get the hang of JavaScript, but still a long way to go. Though I got most of the logic behind the calculator, there's a an issue that I can't seem to figure out. For example someone born on the 15th of September 1977, I am getting that they would be 44years, 21 months, and 10days instead of 44years, 10months and 10 days. Your comments and feedback would be very much welcome on how I could solve this. Thank you very much.
Please log in to post a comment
Log in with GitHubCommunity feedback
- P@elyyyse
Hey, Malick - I think the error might be caused by a backwards greater than sign on line 48 of your .js file.
It’s currently written as
if (currentDate.getMonth() < birthDate.getMonth()) { ageMonths += 12; }
, but I think you’re looking for inputs where the birthday has already occurred this year.I hope this helps! I found this challenge difficult and enjoyed reading through your 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