Design comparison
SolutionDesign
Community feedback
- @mmaazkhanherePosted over 1 year ago
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@Hoodie1309Posted over 1 year ago@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 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