This commit is contained in:
Jaycee Go 2023-01-30 19:31:55 +08:00
parent bd7e6163df
commit fb8d306f08
2 changed files with 16 additions and 2 deletions

View File

@ -1,6 +1,19 @@
const sumAll = function() {
const sumAll = function(start, end) {
sum = 0;
if (start > end) {
for (let j = end; j <= start; j++) {
sum += j;
}
} else {
for (let j = start; j <= end; j++) {
sum += j;
}
}
return sum;
};
console.log(sumAll(-10, [1,4]));
// Do not edit below this line
module.exports = sumAll;
// module.exports = sumAll;

View File

@ -0,0 +1 @@
module.exports = sumAll;