BACK

Determine whether a given year is a leap year

check Leap year:




CODE:

function leapyear(year) {
return (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
}


function evShowleap() {
var vlez = document.querySelector("input[type=number]").value;
var ekran = document.querySelector("#ekran");

if(!vlez.trim()) {
ekran.innerHTML = "enter a year";
return;
}

var rezultat = leapyear(vlez);
if (rezultat === true) {
ekran.innerHTML ="Year " + vlez + " is a Leap Year";
} else {
ekran.innerHTML ="Year " + vlez + " is not a Leap Year";
}

}