Rohan Verma
@rohanvronAll comments
- @HvbibaSubmitted 7 months ago
- @Benjihunt97Submitted 7 months ago@rohanvronPosted 7 months ago
Hey Benji,
Your age calculator looks great!
I noticed a small thing with the date accuracy for months other than the current one. The calculation might be off slightly in those cases.
It seems the code needs an adjustment in how it validates birth dates with different months. Here's an idea:
- Use a Date object to create a representation of the entered date (including year and month). Then, use getDate() to retrieve the correct number of days for that specific month and year (including leap year handling).
This approach ensures accurate validation regardless of the month entered. I've included a code snippet to illustrate this solution:
const inputDate = new Date(year, month - 1, day); if ( inputDate.getDate() !== parseInt(day) || inputDate.getMonth() + 1 !== parseInt(month) || inputDate.getFullYear() !== parseInt(year) ) { return false; } return true; };
Just a heads up about the date validation! Overall, your age calculator is a solid foundation. Keep up the good work! 🚀
Marked as helpful1 - @Vaibhav507Submitted 7 months ago@rohanvronPosted 7 months ago
Hi Vaibhav,
Your age calculator app looks great!
However, I noticed a couple of interesting edge cases that might need some attention:
Month Handling: When entering a date like 14/04/2001" (April 14th, 2001), the output shows -> 22 years 12 months and 21days. While technically correct, it might be more intuitive for users to see this as 23 years 00 months and 21 days. Perhaps there's an opportunity to simplify the output by combining years and months when exceeding 12 months.
Input Validation: Currently, it seems like negative numbers and future dates are accepted as input. For a more user-friendly experience, it might be beneficial to implement some basic validation. For example, users shouldn't be able to enter negative birthdates or dates exceeding the current year.
Just some thoughts to consider! Overall, your age calculator is really cool. Keep up the good work!
Marked as helpful1 - @joshjavierSubmitted 7 months agoWhat are you most proud of, and what would you do differently next time?
I'm proud of the way I structured my code. I think I did a pretty good job dividing code into components and modules that have distinct responsibilities, so it would be easier for other devs (or myself in the future) to understand the code and improve it.
I also feel more confident in deciding when or not to use an external package to solve a problem. In this case, implementing the form without a form library is possible, but I decided to use React Hook Form because it seemed like a good balance between ease of development (I don't have to implement the error validation from scratch) and the performance hit on the app (package size is pretty small at 8.5KB).
What challenges did you encounter, and how did you overcome them?For working with dates, JavaScript's built-in
What specific areas of your project would you like help with?Date
class proved sufficient for this app. One gotcha I encountered was that theDate()
constructor doesn't throw an error when passed an invalid date. For example, creating aDate
object for April 31, 1995 will be evaluated to May 1, 1995. So, to check for invalid dates, I compared the input date and the parsed date. If they're not equal, then the form won't pass validation.Any feedback on the animations? I added it last and didn't want to over-optimize, but I feel like it could use more oomph. It's my first time using React Spring, so I'm still not aware of its full capabilities. Anyway, constructive feedback is welcome!
- @Mrst12Submitted 7 months agoWhat are you most proud of, and what would you do differently next time?
I'm glad that I kept going with my project, i've been working a lot with tailwindcss so my vanilla CSS is a bit rusty, so I need to work on that a little. I would try to refactor the challenge a little next time as probably went a bit over the top creating the project.
What challenges did you encounter, and how did you overcome them?I struggled with figma as it was the first time using it, so i really need some practice on using design files. I saw a few basic tutorials to get me going which was really helpful.
What specific areas of your project would you like help with?This was my first challenge so any feedback would be appreciated, trying to boost my confidence with my skills really.
@rohanvronPosted 7 months agoGreat Work Lisa! Congratulations on completing your first challenge!
0