Instructor
Yogesh Chawla Replied on 17/01/2022
Try this:
function sumAll(arr) {
var out = 0;
for (var i = Math.min(...arr); i <= Math.max(...arr); i++) {
out += i;
}
return out;
}
console.log(sumAll([1, 4]));
console.log(sumAll([4, 1, 5]));
console.log(sumAll([5, 10, 15, 4]));
console.log(sumAll([10, 2]));
Using rest function parameters(or spread operator)