Design comparison
Solution retrospective
*Hi there
I had many problems with this project. I do not know how to calculate age, and I faced issues with logic. Please, can anyone help me?
Community feedback
- @LouMauriegePosted about 1 year ago
Hi! You made a pretty good job yet.
To calculate difference between two dates you can create two dates and subtract them.
You create the variable date on script.js.line.16, you can create another on with the input values that the user gives you. Then you can subtract those dates, and you'll have the difference between those two dates in milliseconds. After that you just had to divide, this result with the number of milliseconds in one year and the result of it should be the years between your two dates. Then take the modulo of this division and divide it with the numbers of milliseconds in one month and so on till you get the years, month and days between your two dates.
Hope it will help you :)
Marked as helpful1@OUSSAMAACHICHEPosted about 1 year ago@LouMauriege Thanks for this valuable help , Can you explain to me the simple code? π€·ββοΈ
1@LouMauriegePosted about 1 year ago@OUSSAMAACHICHE
Ok, I think that the best code to explain this to you might the code of @HaarithBinSabur go check the github repo to see how he did it. In this ( https://github.com/HaarithBinSabur/age-calculator-component/blob/main/app.js ) javascript file from the line 27 to the line 33, you'll see his method witch is mostly the best one to explain how to calculate age from milliseconds.
Hope it will help feel free to ask more questions if needed ;)
Marked as helpful1@LouMauriegePosted about 1 year ago@OUSSAMAACHICHE It's allways a pleasure to help, and it also making me learn a lot so it's a win win.
0
Please log in to post a comment
Log in with GitHubJoin 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