Passed returns ERROR with negative numbers
This commit is contained in:
parent
607fcec7ca
commit
24cf26a15f
|
@ -16,6 +16,11 @@ const sumAll = function(...args) {
|
|||
lastNumber = tempNumber;
|
||||
}
|
||||
|
||||
/*If either number is negative, return 'ERROR' */
|
||||
if (firstNumber < 0 || lastNumber < 0) {
|
||||
return 'ERROR';
|
||||
}
|
||||
|
||||
for (let i = firstNumber; i <= lastNumber; i++) {
|
||||
totalOfNumbers += i;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('sumAll', function() {
|
|||
it('works with larger number first', function() {
|
||||
expect(sumAll(123, 1)).toEqual(7626);
|
||||
});
|
||||
xit('returns ERROR with negative numbers', function() {
|
||||
it('returns ERROR with negative numbers', function() {
|
||||
expect(sumAll(-10, 4)).toEqual('ERROR');
|
||||
});
|
||||
xit('returns ERROR with non-number parameters', function() {
|
||||
|
|
Loading…
Reference in New Issue