From 51494e8eedfc4410d4f000b35927ff2e77c84b5e Mon Sep 17 00:00:00 2001 From: Fredrik Uddenfeldt Date: Sat, 20 May 2023 22:40:38 +0200 Subject: [PATCH] passed 1st and 2nd test but fails rest --- 05_sumAll/sumAll.js | 16 ++++------------ 05_sumAll/sumAll.spec.js | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/05_sumAll/sumAll.js b/05_sumAll/sumAll.js index f0bcded..a9479e2 100644 --- a/05_sumAll/sumAll.js +++ b/05_sumAll/sumAll.js @@ -1,25 +1,17 @@ -// First iteration pseudocode: -// Take two arguments. -// Loop between them. -// Store the value -// If negative or or non-number parameters: return ERROR -// -// - -// First iteration with a faulty but promosing loop: - const sumAll = function(x, y) { let theSum; for (let i = x+1; i <=y; i++) { theSum = x += i } - return(theSum) + return theSum + + if (x | y <0 ) {return('ERROR')} + }; - // Need to add conditions for ERROR-message diff --git a/05_sumAll/sumAll.spec.js b/05_sumAll/sumAll.spec.js index 1a9fb7c..6c53087 100644 --- a/05_sumAll/sumAll.spec.js +++ b/05_sumAll/sumAll.spec.js @@ -4,10 +4,10 @@ describe('sumAll', () => { test('sums numbers within the range', () => { expect(sumAll(1, 4)).toEqual(10); }); - test.skip('works with large numbers', () => { + 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', () => {