# Get Age JavaScript

**URL:** <https://forum.kirupa.com/t/get-age-javascript/79196>\
**Category:** web dev\
**Created:** [February 11, 2005, 4:46pm UTC](https://forum.kirupa.com/t/get-age-javascript/79196 "2005-02-11T16:46:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DESIGN\_GEEZER](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@DESIGN\_GEEZER](https://forum.kirupa.com/u/DESIGN_GEEZER)\
**Post date:** [February 11, 2005, 4:46pm UTC](https://forum.kirupa.com/t/get-age-javascript/79196/1 "2005-02-11T16:46:26Z")

</div>

I’m trying to express my age on my ABOUT page using javascript so I never have to update it. So wrote a JavaScript function.

```auto
 
function MyAge (BirthYear) {
ThisYear = new Date().getFullYear();
YearAge = ThisYear - BirthYear:
document.write("I am "+YearAge+" Years Old");
}

```

It should work. Here are all the dates below and the intended result.

BirthYear = 1982  
ThisYear = 2005  
YearAge = 2005 - 1982  
I am 23 years old…

To me this seems logical. Where am I going wrong?
