Skip to content

fallcoder/age-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

age-calculator

This project is an age calculator created with HTML, CSS, and JavaScript. It allows users to calculate their age based on their date of birth.

Features

  1. The calculateAge() function retrieves the user's date of birth from an HTML element with the ID 'birthdate'.
  2. It checks if a date of birth has been selected. If not, it displays an alert and stops execution.
  3. Then, it retrieves the current date.
  4. The date of birth is converted into a Date object.
  5. The age is calculated by subtracting the birth year from the current year, then the months and days are also calculated.
  6. There is a check for leap years, adjusting the age if the birth date falls after the current date in the same year.
  7. Finally, the result is displayed in an HTML element with the ID 'result'.

Usage:

  • Select your date of birth in the dedicated field.
  • Press the "calculate Age" button to get your age.
  • The result is displayed in years, months, and days.

Author