8000 leap years finished · ambydau/javascript-exercises@aff7e08 · GitHub
[go: up one dir, main page]

Skip to content

Commit aff7e08

Browse files
committed
leap years finished
1 parent 007f147 commit aff7e08

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

leapYears/leapYears.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
const leapYears = function() {
1+
// > Leap years are years divisible by four (like 1984 and 2004). However, years divisible by 100 are not leap years (such as 1800 and 1900) unless they are divisible by 400 (like 1600 and 2000, which were in fact leap years). (Yes, it's all pretty confusing)
22

3+
const leapYears = function(year) {
4+
if(year % 4 === 0){
5+
if((year % 100 === 0) && !(year % 400 === 0)) {
6+
return false;
7+
} else {
8+
return true;
9+
}
10+
} else {
11+
return false;
12+
}
313
}
414

515
module.exports = leapYears

leapYears/leapYears.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ describe('leapYears', function() {
44
it('works with non century years', function() {
55
expect(leapYears(1996)).toEqual(true);
66
});
7-
xit('works with non century years', function() {
7+
it('works with non century years', function() {
88
expect(leapYears(1997)).toEqual(false);
99
});
10-
xit('works with ridiculously futuristic non century years', function() {
10+
it('works with ridiculously futuristic non century years', function() {
1111
expect(leapYears(34992)).toEqual(true);
1212
});
13-
xit('works with century years', function() {
13+
it('works with century years', function() {
1414
expect(leapYears(1900)).toEqual(false);
1515
});
16-
xit('works with century years', function() {
16+
it('works with century years', function() {
1717
expect(leapYears(1600)).toEqual(true);
1818
});
19-
xit('works with century years', function() {
19+
it('works with century years', function() {
2020
expect(leapYears(700)).toEqual(false);
2121
});
2222
});

0 commit comments

Comments
 (0)
0