diff --git a/05_sumAll/sumAll.js b/05_sumAll/sumAll.js index e733b01..16f3de7 100644 --- a/05_sumAll/sumAll.js +++ b/05_sumAll/sumAll.js @@ -1,6 +1,7 @@ const sumAll = function(a, b) { - let sum = 0; - for (let i = a; i <= b; i++) { + let c, sum = 0; + for ((a > b) ? (i = b, c = a) + : (i = a, c = b); i <= c; i++) { sum += i; } return sum; diff --git a/05_sumAll/sumAll.spec.js b/05_sumAll/sumAll.spec.js index e2f1c95..6c53087 100644 --- a/05_sumAll/sumAll.spec.js +++ b/05_sumAll/sumAll.spec.js @@ -7,7 +7,7 @@ describe('sumAll', () => { test('works with large numbers', () => { expect(sumAll(1, 4000)).toEqual(8002000); }); - test.skip('works with larger number first', () => { + test('works with larger number first', () => { expect(sumAll(123, 1)).toEqual(7626); }); test.skip('returns ERROR with negative numbers', () => {