Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

Age calculator with html, css, and jquery

jquery
vernonroque•60
@vernonroque
A solution to the Age calculator app challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Here is my completed project of the age calculator.

I want to ask everyone how you included the leap year in your calculations. Any suggestions?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Alfredo Peguero Capellan•590
    @AlfredoPegueroC
    Posted over 1 year ago

    Hello, @vernonroque

    With the next function, you can retrieve the days of each month.

    function daysInMonth(month, year) {
        return new Date(year, month, 0).getDate();
    }
    

    I hope it helps.

    Marked as helpful
  • Olaniyi Ezekiel•7,580
    @Ezekiel225
    Posted over 1 year ago

    Hello there 👋 @vernonroque.

    Good job on completing the challenge !

    Your project looks really good!

    I have suggestions about your code that might interest you.

    Consider adding a min-height of 100vh to the body element so as to centralize your project.

    body { 
      min-height: 100vh;
      align-items: center;
      display: flex;
      justify-content: center;
    }
    
    

    I hope it helps!

    Other than that, great job!

    Happy coding.

    Marked as helpful
  • P
    Daniel 🛸•44,740
    @danielmrz-dev
    Posted over 1 year ago

    Hello

    Your solution looks great!

    I have two suggestions for improvement:

    • Use <main> to wrap the main content instead of <div>.

    📌 Tags like <div> and <span> are typical examples of non-semantic HTML elements. They serve only as content holders but give no indication as to what type of content they contain or what role that content plays on the page.

    This tag change does not impact your project visually and makes your HTML code more semantic, improving SEO optimization as well as the accessibility of your project.

    • Also, using margin is not the best option to center an element. Here's a very efficient (and better) way to place an element in the middle of the page both vertically and horizontally:

    📌 Apply this to the body (in order to work properly, don't use position or margins):

    body {
        min-height: 100vh;
        display: flex;  /* it works with grid too  */
        justify-content: center;
        align-items: center;
    }
    

    I hope it helps!

    Other than that, great job!

    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub