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
- A year is a leap year if it is divisible by 4.
- Exception: If it is divisible by 100, it is NOT a leap year...
- 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
Input
year = 2000Output
trueExplanation: Divisible by 400 (Success).
02EXAMPLE 2
Input
year = 1900Output
falseExplanation: Divisible by 100 but not 400 (Failure).
Constraints
- Year is a positive integer.
- Return a boolean.
Control FlowMathLogic
JavaScriptSystem handles I/O — write your function only
Loading...
5 Hidden
Input Arguments
year2024
Expected Output
true
Click RUN to test your solution