I wanna replace "was on " to "will be " if the year is greater than the currentYear.
let myDate = new Date();
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ];
const currentYear = myDate.getFullYear();
let tense = 'was on';
for(let year= 2020; year <= 2030; year++){
let d = new Date(year, 4, 27);
if(d.getDate() === 27 && d.getMonth() === 4 ){
const output = `my birthday in ${year} ${tense} ${days[d.getDay()]}`;
console.log(output)
}
}
But when I include an if statement, it's returning nothing - no error, no results.
Aucun commentaire:
Enregistrer un commentaire