The Leap Year Sentinel

MediumAcc. 88.9%
+30 XP 12

Time Correction

A leap year occurs every 4 years to keep our calendar in sync with Earth's orbit. However, there are precise exceptions to prevent time from drifting.

The Rules

  1. A year is a leap year if it is divisible by 4.
  2. Exception: If it is divisible by 100, it is NOT a leap year...
  3. Exception to the Exception: ...UNLESS it is also divisible by 400, in which case it IS a leap year.

Your Task

Receive a year and return true if it is a leap year, otherwise return false.

01EXAMPLE 1

Inputyear = 2000
Outputtrue

Explanation: Divisible by 400 (Success).

02EXAMPLE 2

Inputyear = 1900
Outputfalse

Explanation: Divisible by 100 but not 400 (Failure).

Constraints

  • Year is a positive integer.
  • Return a boolean.
Control FlowMathLogic
JavaScript
Loading...
5 Hidden

Input Arguments

year2024

Expected Output

true

Click RUN to test your solution