8000 Proving harder than I thought and looks like first few conditionals d… · b-cheng/javascript-exercises@b8baa8d · GitHub
[go: up one dir, main page]

Skip to content

Commit b8baa8d

Browse files
committed
Proving harder than I thought and looks like first few conditionals didn't work
1 parent f99ca1b commit b8baa8d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sumAll/sumAll.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const sumAll = function(first, last) {
99
finalSum+=i
1010
}
1111
return finalSum
12-
} else if (first > last){
12+
} else if (first > last) {
1313
//something to figure out how to reverse this
14-
var finalSum=0;
14+
var fakeFirst = first;
1515
first=last;
16-
last=first;
17-
for (var i=last; i <= first; i++) {
16+
last=fakeFirst;
17+
for (var i=first; i <= last; i++) {
1818
finalSum+=i
1919
}
2020
return finalSum

sumAll/sumAll.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ describe('sumAll', function() {
1010
it('works with larger number first', function() {
1111
expect(sumAll(123, 1)).toEqual(7626);
1212
});
13-
xit('returns ERROR with negative numbers', function() {
13+
it('returns ERROR with negative numbers', function() {
1414
expect(sumAll(-10, 4)).toEqual('ERROR');
1515
});
16-
xit('returns ERROR with non-number parameters', function() {
16+
it('returns ERROR with non-number parameters', function() {
1717
expect(sumAll(10, "90")).toEqual('ERROR');
1818
});
19-
xit('returns ERROR with non-number parameters', function() {
19+
it('returns ERROR with non-number parameters', function() {
2020
expect(sumAll(10, [90, 1])).toEqual('ERROR');
2121
});
2222
});

0 commit comments

Comments
 (0)
0