passed 1st and 2nd test but fails rest

This commit is contained in:
Fredrik Uddenfeldt 2023-05-20 22:40:38 +02:00
parent a7d8f414ff
commit 51494e8eed
2 changed files with 6 additions and 14 deletions

View File

@ -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

View File

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