sumAll
This commit is contained in:
parent
bd7e6163df
commit
fb8d306f08
|
@ -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
|
// Do not edit below this line
|
||||||
module.exports = sumAll;
|
// module.exports = sumAll;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
module.exports = sumAll;
|
Loading…
Reference in New Issue