Build a Leap Year Calculator - Build a Leap Year Calculator

Tell us what’s happening:

I don’t understand why I am not getting it.
I get that there is an error in my logic but I am struggling top identify what it is

Your code so far

function isLeapYear(year){
if(year % 4 === 0 && year % 100 === 0 && year % 400 === 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)
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/145.0.0.0 Safari/537.36 Edg/145.0.0.0

Challenge Information:

Build a Leap Year Calculator - Build a Leap Year Calculator

Hi @User_9621

Take a few steps back, add the logic one step at a time.

With 2024 as the value of the year variable, the result should be 2024 is a leap year.

Also, the message should include punctuation.

Happy coding

I want to go just a bit further because it is understandable to want to put all of the conditions together because they are all in the same sentence. But, as Teller suggested, break down the logic bit by bit and examine.

Also, @Teller, this is worth reporting, but the logic steps do not make sense in the steps of the story, but they are correct in the initial opening paragraph.

i.e. this is incorrect because a user will naturally follow the flow of the logic since they are separated into different bullet points.

But this opening paragraph correct because it does group the two pairs of logic required to get a leap year correct.

1 Like

if you think it needs updated please open an issue on github

Ah yes I will. Thank you, ILM. I have been absent from the forums for a time. Appreciate you!

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