passes 5/6 tests
This commit is contained in:
parent
026eb4cd91
commit
a15eafb564
|
@ -1,20 +1,23 @@
|
||||||
|
// Need to figure out how to deal with opposite order (largest first)
|
||||||
|
// and non-integer error with Number.isInteger()
|
||||||
|
|
||||||
const sumAll = function(x, y) {
|
const sumAll = function(x, y) {
|
||||||
let theSum;
|
let theSum;
|
||||||
|
|
||||||
if (x < 0 || y < 0) {return('ERROR')}
|
if (x < 0 || y < 0) {return('ERROR')}
|
||||||
|
|
||||||
|
else if (Number.isInteger(x) == false || Number.isInteger(y) == false) {return('ERROR')}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue