javascript sum of arguments

Solutions on MaxInterview for javascript sum of arguments by the best coders in the world

showing results for - "javascript sum of arguments"
Emely
31 Sep 2016
1const sum = (...input) => {
2  input.reduce((a, b) => a + b)
3}
4
5// Example
6sum(1, 2, 3, 4)
7//output
810
Libbie
30 Nov 2020
1const sum = (...args) => args.reduce((a, b) => a + b);
2
3// Example
4sum(1, 2, 3, 4); //10