odin-default-js-exercises/05_sumAll/sumAll.js

25 lines
313 B
JavaScript

const sumAll = function(x, y) {
let theSum;
if (x < 0 || y < 0) {return('ERROR')}
else
{
for (let i = x+1; i <=y; i++) {
theSum = x += i
}
return theSum
}
};
// Do not edit below this line
module.exports = sumAll;