Answers for "sum all numbers in a range javascript"

12

sum of all numbers in an array javascript

const arrSum = arr => arr.reduce((a,b) => a + b, 0)
Posted by: Guest on March-23-2020
0

sum all numbers in a range javascript

ar sum = 0;
  for (var i = Math.min(...arr); i <= Math.max(...arr); i++) {
    sum += i;
  }
Posted by: Guest on August-11-2020
0

sum range javascript

function sumAll(arr) {
    let fullArr = [];
    let sum = 0;
    const reducer = (accumulator, currentValue) => accumulator + currentValue;
    arr.sort(function(a, b) {
        return a - b
    });
    for (let i = arr[0]; i <= arr[1]; i++) {
        fullArr.push(i);
    }
    sum = fullArr.reduce(reducer);
    return sum;
}
Posted by: Guest on August-17-2020

Code answers related to "sum all numbers in a range javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language