E5D8
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bdf22c8 commit 5bc4b4bCopy full SHA for 5bc4b4b
06_leapYears/leapYears.js
@@ -1,9 +1,16 @@
1
const leapYears = function(givenYear) {
2
+
3
+ // Solution with ifs
4
5
// years divisible by 4 are no leap years
- if(givenYear % 4 !== 0) return false;
6
+ // if(givenYear % 4 !== 0) return false;
7
// century years are no leap years, unless divisible by 400
- if(givenYear % 100 === 0 && givenYear % 400 !== 0) return false;
- return true;
8
+ // if(givenYear % 100 === 0 && givenYear % 400 !== 0) return false;
9
+ // return true;
10
11
+ // very elegantly solution with boolean expression
12
+ return givenYear % 4 === 0 && (givenYear % 100 !== 0 || givenYear % 400 === 0);
13
14
};
15
16
// Do not edit below this line
0 commit comments