-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleap-year.js
More file actions
27 lines (24 loc) · 856 Bytes
/
leap-year.js
File metadata and controls
27 lines (24 loc) · 856 Bytes
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
// leap year or not - simple logic
// year will be leap year if the year is divisible by 4
function is_leap_year (year) {
if (year % 4 === 0) {
return true;
} else {
return false;
}
}
let leap_year = is_leap_year (2044);
// console.log(leap_year);
// those year that is not divisible by 100, if the year is divisible by 4 then it will be a leap year
// those year that is divisible by 100 and 400 it will be a leap year
function is_leap_year_2 (year) {
if (year % 100 !== 0 && year % 4 === 0) {
return true;
} else if (year % 100 === 0 && 400 === 0) {
return true;
} else {
return false;
}
}
let leap_2 = is_leap_year_2 (2120);
console.log(leap_2);