i'm learning how to get the age from birthdate, but no matter what date i put as dob, i will always get 50. Is something still a string in this code ? What's the problem ?
function Person(name, dob) {
this.name = name;
// this.age = age;
this.birthday = new Date(dob);
this.calAge = function(){
const diff = Date.now() - this.birthday.getTime();
const ageDate = new Date(diff);
return Math.abs(ageDate.getUTCFullYear() - 1970);
}
}
const angel = new Person('Angel', 2-3-2004);
console.log(angel.calAge());