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', () => {