If it is a leap year, return the Boolean value True, otherwise, return False.
For a year to be Leap Year either of the following conditions should be true:
It is divisible by 400.
It is divisible by 4 but it is not divisible by 100.
If none of the above conditions is true, then it is not a leap year.
Input
The first line contains the year to be checked.
Constraints:
1900 ≤ year ≤10^5
Output
The function must return a Boolean value (True/False).
function checkYear( year) {
if (year % 400 == 0)
return true;
if (year % 100 == 0)
return false;
if (year % 4 == 0)
return true;
return false;
}
let year = 1900;
document.write(checkYear(1900) ? "True" : "False" );
I have error for this code
/box/script.js:20
document.write(checkYear(1900) ? "True" : "False" );
^