Build a Leap Year Calculator - Build a Leap Year Calculator

Tell us what’s happening:

It’s a very strange question. Questions 5, 6 and 7 can’t be passed at the same time. It seems that he only accepts the value of the last result at a time. When my final result is “2000 is a leap year.” I can pass 6, but I can’t pass 5 and 7, and so can the other two.

Your code so far

function isLeapYear(n)
{
  if(n%4==0&&n%100!=0||n%400==0)
    return year+" is a leap year.";
  else return year+" is not a leap year.";
}

let year,result;

year=2024;
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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0

Challenge Information:

Build a Leap Year Calculator - Build a Leap Year Calculator
https://www.freecodecamp.org/learn/full-stack-developer/lab-leap-year-calculator/build-a-leap-year-calculator

Welcome to the forum @xiaojiangddz

Check which variables your function is returning.

Happy coding

you have n here, right? so inside your function, what is year and what is result?

1 Like

Thank you very much. I didn’t notice this at all