I am facing an issue with the nested if statement where all conditions have been provided. Some leap years like 2016 and 2020 are not being recognized as Leap years even though they should be. Can someone please assist me in fixing this error?
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");
}