Exercise · Operators and type conversion · lesson 12 of 14
Exercise: leap year
Write a function function isLeap(year) that returns true if the year is a leap year, and false otherwise. A year is a leap year when it is divisible by 4 but not by 100. The exception is years divisible by 400: they are leap years.
isLeap(2024)→trueisLeap(1900)→falseisLeap(2000)→true
Constraints: year is a whole number from 1 to 9999.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.