Files
freeCodeCamp/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/69306364df283fcaff2e1ad8.md

1.2 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69306364df283fcaff2e1ad8 Challenge 147: Leap Year Calculator 28 challenge-147

--description--

Given an integer year, determine whether it is a leap year.

A year is a leap year if it satisfies the following rules:

  • The year is evenly divisible by 4, and
  • The year is not evenly divisible by 100, unless
  • The year is evenly divisible by 400.

--hints--

isLeapYear(2024) should return true.

assert.isTrue(isLeapYear(2024));

isLeapYear(2023) should return false.

assert.isFalse(isLeapYear(2023));

isLeapYear(2100) should return false.

assert.isFalse(isLeapYear(2100));

isLeapYear(2000) should return true.

assert.isTrue(isLeapYear(2000));

isLeapYear(1999) should return false.

assert.isFalse(isLeapYear(1999));

isLeapYear(2040) should return true.

assert.isTrue(isLeapYear(2040));

isLeapYear(2026) should return false.

assert.isFalse(isLeapYear(2026));

--seed--

--seed-contents--

function isLeapYear(year) {

  return year;
}

--solutions--

function isLeapYear(year) {
    return ((year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0))
}