passes 3/6 tests
This commit is contained in:
parent
e9b1b13cfa
commit
026eb4cd91
|
@ -1,19 +1,24 @@
|
||||||
const sumAll = function(x, y) {
|
const sumAll = function(x, y) {
|
||||||
let theSum;
|
let theSum;
|
||||||
for (let i = x+1; i <=y; i++) {
|
|
||||||
theSum = x += i
|
if (x < 0 || y < 0) {return('ERROR')}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
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
|
|
||||||
|
|
||||||
|
|
||||||
// Do not edit below this line
|
// Do not edit below this line
|
||||||
module.exports = sumAll;
|
module.exports = sumAll;
|
||||||
|
|
|
@ -7,16 +7,16 @@ describe('sumAll', () => {
|
||||||
test('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('returns ERROR with negative numbers', () => {
|
test('returns ERROR with negative numbers', () => {
|
||||||
expect(sumAll(-10, 4)).toEqual('ERROR');
|
expect(sumAll(-10, 4)).toEqual('ERROR');
|
||||||
});
|
});
|
||||||
test.skip('returns ERROR with non-number parameters', () => {
|
test('returns ERROR with non-number parameters', () => {
|
||||||
expect(sumAll(10, "90")).toEqual('ERROR');
|
expect(sumAll(10, "90")).toEqual('ERROR');
|
||||||
});
|
});
|
||||||
test.skip('returns ERROR with non-number parameters', () => {
|
test('returns ERROR with non-number parameters', () => {
|
||||||
expect(sumAll(10, [90, 1])).toEqual('ERROR');
|
expect(sumAll(10, [90, 1])).toEqual('ERROR');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue