Tell us what’s happening:
Failing steps 5 and 6 even though the console output is correct for all 3 years. The only thing i can think of is that it doesn’t like the “if else” statement. Any other ideas?
Your code so far
let year;
function isLeapYear(num) {
if (num %4 === 0 && num %100 !== 0 || num %4 === 0 && num %400 === 0) {
return `${year} is a leap year.`;
}
else
return `${year} is not a leap year.`;
}
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 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Challenge Information:
Build a Leap Year Calculator - Build a Leap Year Calculator