Q:

Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar

0

Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function leapyear(year)
{
return (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
}
console.log(leapyear(2016));
console.log(leapyear(2000));
console.log(leapyear(1700));
console.log(leapyear(1800));
console.log(leapyear(100));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now