Build a Leap Year Calculator - Build a Leap Year Calculator

Tell us what’s happening:

I keep failing test numbers 5-7 (test 5 question)"With [2024] as the value of [year] variable, the result should be [2024 is a leap year.]. " I have tested various years and I believe my function is running correctly, my console.log is giving me the correct results. However i still find the that i am not passing the test questions. Is there a wording or clue i am missing from the user stories?

This is the results of the test:
// running tests 5. With

2024

as the value of the

year

variable, the

result

should be

2024 is a leap year.

. 6. With

2000

as the value of the

year

variable, the

result

should be

2000 is a leap year.

. 7. With

1900

as the value of the

year

variable, the

result

should be

1900 is not a leap year.

. // tests completed //
console output
2024 is a leap year
2000 is a leap year
1900 is not a leap year

Your code so far

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

let 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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36

Challenge Information:

Build a Leap Year Calculator - Build a Leap Year Calculator

Missing a dot in the end of returning strings in if else statement.

2 Likes

Hi,
you’ve done great so far. You’re just missing a period . at the end of some of your texts.

" is a leap year"
" is not a leap year"
" is a leap year"

I just put in a period after the strings, but 6 still fails.

1 Like

You didn’t have dot in above return statements

1 Like

It’s such a simple mistake, thank you for the help!

1 Like