Build a Leap Year Calculator - Build a Leap Year Calculator

Tell us what’s happening:

my code is correct but for some reason the results aren’t passing

Your code so far

const isLeapYear = (num) => {

  if (num % 4 === 0 && num % 100 === 0) {
    if (num % 400 !== 0) {
      return `${year} is not a leap year.`
    } else {
      return `${year} is a leap year.`
    } 
  } else if (num % 4 === 0 && num % 100 !== 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);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

Build a Leap Year Calculator - Build a Leap Year Calculator

You used year in your function instead of the passed argument num.

That should be okay since you are passing the global variable year as the argument, but it causes issues for the test, because it will not change year, it will directly call the function with a different argument.

Try adding this at the end:

console.log(isLeapYear(2024));

thank you so much, i’ve gotten around it.