2021-04-30 10:12:52 +00:00
|
|
|
const sumAll = function(min, max) {
|
|
|
|
if (!Number.isInteger(min) || !Number.isInteger(max)) return "ERROR";
|
|
|
|
if (min < 0 || max < 0) return "ERROR";
|
|
|
|
if (min > max) {
|
|
|
|
const temp = min;
|
|
|
|
min = max;
|
|
|
|
max = temp;
|
|
|
|
}
|
|
|
|
let sum = 0;
|
|
|
|
for (let i = min; i < max + 1; i++) {
|
|
|
|
sum += i;
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
};
|
2017-11-24 20:23:16 +00:00
|
|
|
|
2021-04-30 10:12:52 +00:00
|
|
|
module.exports = sumAll;
|