In the nested if statement, I have given all the conditions. But some leap years are not being shown as Leap year. For eg: 2000 is coming as a leap year, but year like 2016, 2020 aren't being considered as a leap year. Please Help.
var y = prompt("Enter the year");
if (y % 4 === 0) {
if (y % 100 === 0) {
if (y % 400 === 0) {
alert(y + " is a leap year");
} else {
alert(y + " is not a leap year");
}
} else {
alert(y + " is not a leap year");
}
} else {
alert(y + " is not a leap year");
}
Aucun commentaire:
Enregistrer un commentaire