Build a Leap Year Calculator - Build a Leap Year Calculator

Tell us what’s happening:

I passed, but when I looked at other people’s code, it was very different from mine. Should I adjust the way I write my code? Or is there something I should know or improve? I’d really appreciate your advice!

Your code so far

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

let year = 2025;

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/138.0.0.0 Safari/537.36 Edg/138.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

that’s really normal, there are many ways to solve these labs

you did good

1 Like

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