8000 add leapYears · dbateman3/javascript-exercises@cadd4b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit cadd4b2

Browse files
committed
add leapYears
1 parent 5c559cf commit cadd4b2

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ The first exercise, `helloWorld` will walk you through the process in more depth
1212

1313

1414
## planned exercises (in no particular order for the moment):
15-
1. book titles
16-
1. leap years
15+
1. book titles (MC)
16+
1. leap years
1717
1. Caesar Cipher
1818
1. Palindromes
1919
1. Pangrams
20-
1. pig latin
20+
1. pig latin (MC)
2121
1. fibonacci
2222
1. convert to snake case

leapYears/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Exercise XX - leapYears
2+
3+
Create a function that determines whether or not a given year is a leap year. Leap years are determined by the following rules:
4+
5+
>There is a leap year every year whose number is perfectly divisible by four - except for years which are both divisible by 100 and not divisible by 400. The second part of the rule effects century years. For example; the century years 1600 and 2000 are leap years, but the century years 1700, 1800, and 1900 are not.
6+
7+
```javascript
8+
leapYears(2000) // is a leap year: returns true
9+
leapYears(1985) // is not a leap year: returns false
10+
```
11+

leapYears/leapYears.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var leapYears = function() {
2+
3+
}
4+
5+
module.exports = leapYears

leapYears/leapYears.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var leapYears = require('./leapYears')
2+
3+
describe('leapYears', function() {
4+
it('works with non century years', function() {
5+
expect(leapYears(1994)).toEqual(true);
6+
});
7+
xit('works with non century years', function() {
8+
expect(leapYears(1997)).toEqual(false);
9+
});
10+
xit('works with ridiculously futuristic non century years', function() {
11+
expect(leapYears(34992)).toEqual(true);
12+
});
13+
xit('works with century years', function() {
14+
expect(leapYears(1900)).toEqual(false);
15+
});
16+
xit('works with century years', function() {
17+
expect(leapYears(1400)).toEqual(true);
18+
});
19+
xit('works with century years', function() {
20+
expect(leapYears(700)).toEqual(false);
21+
});
22+
});

0 commit comments

Comments
 (0)
0