Modo entrevista. Temporizador de 5 min, sin pistas y sin autocompletado
Leap year
FácilBasics5 min
Write a function isLeapYear(year) that returns true if the year is a leap year and false if it is not.
- The parameter
yearis an integer from 1 to 9999. - A year is a leap year if it divides by 4 with no remainder:
2024is a leap year,2023is not. - Exception: a year that divides by 100 is a leap year only if it also divides by 400.
1900is not a leap year,2000is. - Return a boolean:
trueorfalse, not the string'true'.
Ejemplos
isLeapYear(2024)Devuelve true
isLeapYear(1900)Devuelve false
isLeapYear(2000)Devuelve true
Preguntada en Infosys · Fuente
Cargando el editor…
- Entrada
isLeapYear(2024)Esperadotrue - Entrada
isLeapYear(2023)Esperadofalse - Entrada
isLeapYear(1900)Esperadofalse - Entrada
isLeapYear(2000)Esperadotrue
Las pruebas ocultas se ejecutan al enviar