Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 803 Bytes

leap-years.md

File metadata and controls

31 lines (22 loc) · 803 Bytes

Leap Years 7 Kyu

LINK TO THE KATA - DATE TIME ALGORITHMS

Description

In this kata you should simply determine, whether a given year is a leap year or not. In case you don't know the rules, here they are:

  • years divisible by 4 are leap years
  • but years divisible by 100 are not leap years
  • but years divisible by 400 are leap years

Additional Notes:

  • Only valid years (positive integers) will be tested, so you don't have to validate them

Solution

const isLeapYear = year => {
  if (year % 400 === 0) return true
  if (year % 100 === 0) return false
  if (year % 4 === 0) return true

  return false
}