Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sum values in array javascript

const num = [1, 3, 1, 1] 
const reducer = (accumulator, currentValue) => accumulator + currentValue;
const sum = num.reduce(reducer);
console.log(sum)
// (1+3+1+1) = 6
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sum #values #array #javascript
ADD COMMENT
Topic
Name
9+4 =