2017-12-15 19:43:38 +00:00
|
|
|
const sumAll = function(min, max) {
|
|
|
|
if (min < 0 || max < 0) return "ERROR";
|
|
|
|
if (typeof min !== "number" || typeof max !== "number") 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-08-24 13:26:01 +00:00
|
|
|
|
2017-12-15 19:43:38 +00:00
|
|
|
module.exports = sumAll;
|