I have to check the age validation, so I have tried the following method for getting age:
let newDate = new Date(this.userDob);
var timeDiff = Math.abs(Date.now() - newDate);
let age = Math.floor((timeDiff / (1000 * 3600 * 24)) / 365);
here this.userDob is a string. How can I use this string to get age using javascript?