Build a Leap Year Calculator - Build a Leap Year Calculator

Tell us what’s happening:

The results work in the console but can’t complete the challenge the challenge.

let year = 1900;

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

let result = isLeapYear(year);

console.log(result);

Your code so far

let year = 1900;

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

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/137.0.0.0 Safari/537.36

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

do you think that your function is reusable? would you expect a different value from isLeapYear(2004) and isLeapYear(2005)?

The results are different.

That’s not what I asked you to test, and with this you will not see the issue, test exactly what I suggested

bro how to reusable the function more other times, because when I written this code

I wanna to use another time function like
let year = 2000;
let result = isLeapYear(year)
;

let year = 1900;
let result = isLeapYear(year)
;

Welcome to the forum :wave:

Please open a new thread

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Get Help > Ask for Help button located on the challenge.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.