Leap year checker

JavaScript
Easy

Objective

Write a function that calculates if a given year is a leap year

Logic

A year is a leap year IF:

  1. It can be divided exactly by 4

  2. Except: if it can also be divided exactly by 100

  3. Except: it it can aslo be divided exactly by 400

Requirements

  1. The function should be called isLeapYear

  2. It should take a single parameter, year which should be a number

  3. It should return true if the year is a leap year, else it should return false

  4. You should NOT use any JavaScript date functions or libraries

Check your solution

Tests

Function name is isLeapYear
isLeapYear(2023)Expected:false
isLeapYear(2020)Expected:true
isLeapYear(2000)Expected:true
isLeapYear(1900)Expected:false