Basically I'm trying to create a validator for birthdays using the last information (mm/dd) but it is not returning the value as expected
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0');
today = mm + '/' + dd;
var newday = today.toString();
var birthday = "1992/09/21";
var monthday = birthday.substr(birthday.length - 5);
function validator(newday, birthday) {
if (monthday === newday) {
console.log('True');
return true;
}
else {
console.log('False');
return false
}
}
validator();
console.log(newday, monthday)
Aucun commentaire:
Enregistrer un commentaire