The below answer is the way to go if the age is just for display purposes (Might not be 100% accurate) but atleast it is easier to wrap your head around
function age(birthdate){
return Math.floor((new Date().getTime() - new Date(birthdate).getTime()) / 3.154e+10)
}