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

Skip to content

Commit fe087fd

Browse files
committed
add sumAll
1 parent 4c8f164 commit fe087fd

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

05-sumAll/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Exercise 05 - sumAll
2+
3+
Implement a function that takes 2 integers and returns the sum of every number between(and including) them:
4+
5+
```javascript
6+
sumAll(1, 4) // returns the sum of 1 + 2 + 3 + 4 which is 10
7+
```

05-sumAll/sumAll.js

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

05-sumAll/sumAll.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var sumAll = require('./sumAll')
2+
3+
describe('sumAll', function() {
4+
it('sums numbers within the range', function() {
5+
expect(sumAll(1, 4)).toEqual(10);
6+
});
7+
xit('works with large numbers', function() {
8+
expect(sumAll(1, 4000)).toEqual(8002000);
9+
});
10+
xit('works with larger number first', function() {
11+
expect(sumAll(123, 1)).toEqual(7626);
12+
});
13+
xit('returns ERROR with negative numbers', function() {
14+
expect(sumAll(-10, 4)).toEqual('ERROR');
15+
});
16+
xit('returns ERROR with non-number parameters', function() {
17+
expect(sumAll(10, "90")).toEqual('ERROR');
18+
});
19+
xit('returns ERROR with non-number parameters', function() {
20+
expect(sumAll(10, [90, 1])).toEqual('ERROR');
21+
});
22+
});

0 commit comments

Comments
 (0)
0