Tell us what’s happening:
I don’t understand why I am not passing the tests. I am failing tests 6 and 7 when I put the variable year with value 2024 and then the result variable. But if I change year for 2000 then test number 5 and 7 fails. I put the logs of “if1” to check if it is getting the return from the correct if
Your code so far
function isLeapYear (numYear) {
if (numYear % 4 == 0 && numYear % 100 == 0 && numYear % 400 == 0){
console.log("if1")
return `${year} is a leap year.`
} else if (numYear % 4 == 0 && numYear % 100 == 0){
console.log("if2")
return `${year} is not a leap year.`
} else if (numYear % 4 == 0){
console.log("if3")
return `${year} is a leap year.`
} else {
console.log("if4")
return `${year} is not a leap year.`
}
}
let year = 2000
let result = isLeapYear(year)
console.log(result)
year = 2024
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/144.0.0.0 Safari/537.36
Challenge Information:
Build a Leap Year Calculator - Build a Leap Year Calculator