JSFiddle - React, Tailwind, and code Playground

by Joel Ferreira

JavaScript

function calcAge(birthYear,birthMonth, birthDay) {
  var birthday = +new Date(birthYear, birthMonth, birthDay);
  return~~ ((Date.now() - birthday) / (31557600000));
}

function isOfAge(birthDate) {

    var today = new Date();

    var birthday = +new Date(birthDate.getFullYear(), birthDate.getMonth(), birthDate.getDay());
  return~~ ((Date.now() - birthday) / (31557600000));
}


document.write("She is " + isOfAge(new Date(1993,05,30)) + " years old" );