-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleapYear.js
43 lines (36 loc) · 787 Bytes
/
leapYear.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* year will be a leap year if the year is divisible by 4
*
*/
function isLeapYear (year) {
if (year % 4 === 0){
return true;
}
else{
return false;
}
}
const isLipi = isLeapYear(2052);
console.log(isLipi);
/**
* 1. those year that is not divisible by 100, if the year is divisible 4;
* then it will be a leap year;
* 2. if the year is divisible by 400, then it is leap year;
* 3. else it is not a leap year
*/
function isLeapYear2 (year) {
if (year % 100 !== 0 && year % 4 === 0){
return true;
}
else if (year % 400 === 0){
return true;
}
else{
return false;
}
}
const isLeap = isLeapYear2(2100);
const isLeap2 = isLeapYear2(2400);
const isLeap3 = isLeapYear2(1900);
const isLeap4 = isLeapYear2(2052);
console.log(isLeap, isLeap, isLeap3, isLeap4);