From 77972b42821bccfbfef370f0cd4d463f65fd9537 Mon Sep 17 00:00:00 2001 From: NetMan <13informatyka14@gmail.com> Date: Fri, 5 Jan 2024 21:46:07 +0100 Subject: [PATCH] Passes test 4 from exercise 05 --- 05_sumAll/sumAll.js | 3 +++ 05_sumAll/sumAll.spec.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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', () => {