js leap year calculator

Solutions on MaxInterview for js leap year calculator by the best coders in the world

showing results for - "js leap year calculator"
Irene
07 Jul 2018
1// https://www.mathsisfun.com/leap-years.html 
2function isLeapYear(year) {
3 
4    if(year % 400 === 0){
5        return ("yes");
6    } if(year % 100 === 0){
7        return ("no");
8    } if (year % 4 === 0){
9        return ("yes");
10    } else {
11        return ("no");
12    }
13    
14
15}
16
17
18isLeap(2024);
Maryam
04 Jul 2016
1// https://www.mathsisfun.com/leap-years.html 
2function isLeapYear(year) { 
3
4    if(year % 400 === 0){
5        return (year + " is a leap year.");
6    } if(year % 100 === 0){
7        if(year % 400 === 0){
8            return (year + " is a leap year.");
9        } else {
10          return (year + " is not a leap year.");
11        }
12    } if (year % 4 === 0){
13        if(year % 100 === 0){
14           return (year + " is not a leap year.");
15        } else {
16        return (year + " is a leap year.");
17        }
18    } else {
19        return (year + " is not a leap year.");
20    }
21
22}
23
24// leap year
25// isLeap(2024);
26
27// not leap year 
28// isLeap(1930);
29