8000 Add solution to leapYear · b-cheng/javascript-exercises@7b52c97 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7b52c97

Browse files
committed
Add solution to leapYear
1 parent e669458 commit 7b52c97

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

leapYears/leapYears.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
const leapYears = function() {
2-
1+
const leapYears = function(year) {
2+
//if year%4 is perfectly divisiable
3+
if (year%4==0 && (year%100!=0 || year%400 ==0)) {
4+
return true
5+
} else {
6+
return false
7+
}
38
}
49

510
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