//Easiest Leap-year condition
function isLeapyear(year){
if(year%4==0 || year%400==0 && year%1000!=0){
return true;
}
else{
return false;
}
}
const my_year = isLeapyear(1999); //Tip: 2000 is a leap year.
console.log('My year is', my_year );
function isLeapYear(year){
if(year % 400 === 0 && year % 4 === 0){
return true
} else {
return false
}
}
function isLeapYear(year) {
if (year % 4 == 0) {
console.log("leap year")
} else {
console.log("Not a leap year")
}
}
var myYear = 2020;
isLeapYear(myYear)
// Output:leap year
<script>
// Javascript program to check
// for a leap year
function checkYear( year) {
// If a year is multiple of 400,
// then it is a leap year
if (year % 400 == 0)
return true;
// Else If a year is multiple of 100,
// then it is not a leap year
if (year % 100 == 0)
return false;
// Else If a year is multiple of 4,
// then it is a leap year
if (year % 4 == 0)
return true;
return false;
}
// Driver method
let year = 2000;
document.write(checkYear(2000) ? "Leap Year" : "Not a Leap Year");
// This code is contributed by shikhasingrajput
</script>