Answers for "avascript sum of arguments"

8

javascript sum of arguments

const sum = (...input) => {
  input.reduce((a, b) => a + b)
}

// Example
sum(1, 2, 3, 4)
//output
10
Posted by: Guest on June-21-2021
2

avascript sum of arguments

x = sumAll(1, 123, 500, 115, 44, 88);

function sumAll() {
  let sum = 0;
  for (let i = 0; i < arguments.length; i++) {
    sum += arguments[i];
  }
  return sum;
}
Posted by: Guest on June-21-2021
1

javascript sum of arguments

const sum = (...args) => args.reduce((a, b) => a + b);

// Example
sum(1, 2, 3, 4); //10
Posted by: Guest on July-03-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language