passed 1st and 2nd test but fails rest
This commit is contained in:
parent
a7d8f414ff
commit
51494e8eed
|
@ -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) {
|
const sumAll = function(x, y) {
|
||||||
let theSum;
|
let theSum;
|
||||||
for (let i = x+1; i <=y; i++) {
|
for (let i = x+1; i <=y; i++) {
|
||||||
theSum = x += i
|
theSum = x += i
|
||||||
}
|
}
|
||||||
|
|
||||||
return(theSum)
|
return theSum
|
||||||
|
|
||||||
|
if (x | y <0 ) {return('ERROR')}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Need to add conditions for ERROR-message
|
// Need to add conditions for ERROR-message
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@ describe('sumAll', () => {
|
||||||
test('sums numbers within the range', () => {
|
test('sums numbers within the range', () => {
|
||||||
expect(sumAll(1, 4)).toEqual(10);
|
expect(sumAll(1, 4)).toEqual(10);
|
||||||
});
|
});
|
||||||
test.skip('works with large numbers', () => {
|
test('works with large numbers', () => {
|
||||||
expect(sumAll(1, 4000)).toEqual(8002000);
|
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);
|
expect(sumAll(123, 1)).toEqual(7626);
|
||||||
});
|
});
|
||||||
test.skip('returns ERROR with negative numbers', () => {
|
test.skip('returns ERROR with negative numbers', () => {
|
||||||
|
|
Loading…
Reference in New Issue