# How do I use Validate Age Calculator?

Hello, how do I validate the age calculator in my code:

Calculate Age
``````<input type="text" id="firstname" placeholder="First Name">
<input type="text" id="dob" placeholder="Date of Birth">

<!-- Button to start -->
<button type="button" id="calculateClicked">
Calculate
</button>

<!-- Below is where the result is displayed  -->
<div id="userAge"></div>

<script
</script>

<script>

\$( () => {

\$("#calculateClicked").click( calculateAge );

} );

function calculateAge(){
// Get number of milliseconds in a year
// DaysInYear * HoursInDay * MinutesInHour * SecondsInMinute * MillisecondsInSecond
// Could be "HardCoded" to 31536000000
const millisecondsInAYear = 365.2423 * 24 * 60 * 60 * 1000;

let firstname = \$("#firstname").val();
let dob = \$("#dob").val();

// Get Difference between Start Date and now
var ageInMilliseconds = (new Date() - Date.parse(dob));

// Get Age in years by dividing ageInMilliseconds by millisecondsInAYear
var ageInYears = ageInMilliseconds / millisecondsInAYear;

// Display result by using document object to
\$("#userAge").text(`\${firstname} is \${ageInYears} years old.` );

}
</script>
``````

You have directions right there.

``````// Get number of milliseconds in a year
// DaysInYear * HoursInDay * MinutesInHour * SecondsInMinute * MillisecondsInSecond
// Could be "HardCoded" to 31536000000
const millisecondsInAYear = 365.2423 * 24 * 60 * 60 * 1000;
``````

Then

`````` // Get Difference between Start Date and now
var ageInMilliseconds = (new Date() - Date.parse(dob));

// Get Age in years by dividing ageInMilliseconds by millisecondsInAYear
var ageInYears = ageInMilliseconds / millisecondsInAYear;

// Display result by using document object to
\$("#userAge").text(`\${firstname} is \${ageInYears} years old.` );
``````

Coding is about indenifying small problems and solving them one by one.
So your first step should be to get the date in javascript. We all google, don’t be ashamed

Yeah, I tried that, but I’m still lost.