how to find leap year in javascript code example
Example 1: javascript leap year
function isLeapYear(year){
if(year % 400 === 0 && year % 4 === 0){
return true
} else {
return false
}
}
Example 2: find leap year javascript
function isLeap(year) {
if (year % 4 === 0) {
if (year % 100 === 0){
if (year % 400 == 0){
return ("Leap year.");
} else {
return ("Not leap year.");
}
} else {
return ("Leap year.");
}
} else{
return ("Not leap year.");
}
}
Example 3: how to check leap year in javascript
function isLeapYear(year) {
if (year % 400 === 0) return true;
if (year % 100 === 0) return false;
return year % 4 === 0;
}