Tell us what’s happening:
My code seems to work as I can pass any year into it and get correct results in the console. However, it keeps failing tests 5, 6, 7 depending on which year I check last in my code.
For example, checking 2024 last lets me pass test 5, but 6 and 7 fail.
Checking 1990 last lets me pass test 7, but 5, 6 fail.
I feel like my code is functional, but I’m missing something specific FCC is expecting. Any ideas? Thanks!
Your code so far
function isLeapYear(num) {
if (num % 4 === 0 && !(num % 100 === 0) ) {
return `${year} is a leap year.`
}
else if (num % 400 === 0) {
return `${year} is a leap year.`
}
else {
return `${year} is not a leap year.`
}
};
let year = 2024;
let result = isLeapYear(year);
console.log(result);
year = 2000;
result = isLeapYear(year);
console.log(result);
year = 1900;
result = isLeapYear(year);
console.log(result);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36
Challenge Information:
Build a Leap Year Calculator - Build a Leap Year Calculator