showing results for - "avascript sum of arguments"
Bianca
01 Jan 2020
1const sum = (...input) => {
2  input.reduce((a, b) => a + b)
3}
4
5// Example
6sum(1, 2, 3, 4)
7//output
810
Karsten
04 Jul 2018
1x = sumAll(1, 123, 500, 115, 44, 88);
2
3function sumAll() {
4  let sum = 0;
5  for (let i = 0; i < arguments.length; i++) {
6    sum += arguments[i];
7  }
8  return sum;
9}
Maureen
29 Apr 2019
1const sum = (...args) => args.reduce((a, b) => a + b);
2
3// Example
4sum(1, 2, 3, 4); //10