I would like some constructive feedback

I am currently doing the Frontend Mentor Challenge "Age Calculator" (https://www.frontendmentor.io/challenges/age-calculator-app-dF9DFFpj-Q) and I'd appreciate some constructive feedback about my CSS and JavaScript: https://codepen.io/lena-s98/pen/GRPGXOe But please avoid opinionated feedback like "Don't use comments", etc ... I'm struggling to get the age calculation to work correctly. Maybe someone can nudge me into the right direction 🙂
Frontend Mentor
Frontend Mentor | Age calculator app coding challenge
This challenge is designed to sharpen your JavaScript and form validation skills. Working with dates in JavaScript can be tricky, so this will be a nice test!
10 Replies
MartynasXS
MartynasXS•14mo ago
whats wrong with the calculation seems to calculate it fine
lena_neko
lena_neko•14mo ago
When I use my birthdate it's one month off for example. And when you use the current month 10 then it breaks completly 😅 and it's kinda hard for me to figure out what to do about it.
MartynasXS
MartynasXS•14mo ago
Oh for that i'd use absolute time rather than trying to get the month day and year separately lemme just try something
lena_neko
lena_neko•14mo ago
I thought about doing that but then decided to do each seperately
MartynasXS
MartynasXS•14mo ago
the code you have is unnecessarily complicated for one. I'd save month/day relations in an array/object first. then you could replace all your ifs with months[monthValue] === 31 or appropriate month day counts then you'd borrow days from previous month and decrease month count and do similar thing with years. @lena_neko
lena_neko
lena_neko•14mo ago
@MartynasXS oki I'll look into implementing it that way. thank you
MartynasXS
MartynasXS•14mo ago
also here
No description
MartynasXS
MartynasXS•14mo ago
you dont check if months are equal you can just change < into <= in the first if statement
lena_neko
lena_neko•14mo ago
I see. Fixed it 🙂
MartynasXS
MartynasXS•14mo ago
as for css im no expert but it looks nice visually so i wont question anything.
Want results from more Discord servers?
Add your server