Is it a leap year?
- O(1) · Trivial
- Free
- Python
- JavaScript
- conditionals
- booleans
Problem
A year is a leap year if it's a multiple of 4, but not if it's also a multiple of 100; and it counts again if it's a multiple of 400. That's why 2024 is a leap year, 1900 wasn't and 2000 was.
Write a function that takes a year and returns true or false.
Examples
2024 → true
2023 → false
A multiple of 100
1900 → false
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def is_leap_year(year):
passJavaScript
function isLeapYear(year) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.