diff --git a/05_sumAll/sumAll.js b/05_sumAll/sumAll.js index 16f3de7..8ee567f 100644 --- a/05_sumAll/sumAll.js +++ b/05_sumAll/sumAll.js @@ -1,4 +1,7 @@ const sumAll = function(a, b) { + if (a < 0 || b < 0) { + return "ERROR"; + } let c, sum = 0; for ((a > b) ? (i = b, c = a) : (i = a, c = b); i <= c; i++) { diff --git a/05_sumAll/sumAll.spec.js b/05_sumAll/sumAll.spec.js index 6c53087..7927aae 100644 --- a/05_sumAll/sumAll.spec.js +++ b/05_sumAll/sumAll.spec.js @@ -10,7 +10,7 @@ describe('sumAll', () => { test('works with larger number first', () => { expect(sumAll(123, 1)).toEqual(7626); }); - test.skip('returns ERROR with negative numbers', () => { + test('returns ERROR with negative numbers', () => { expect(sumAll(-10, 4)).toEqual('ERROR'); }); test.skip('returns ERROR with non-number parameters', () => {