add all the elements of an array javascript code example
Example 1: sum all elements in array javascript
arr.reduce((a, b) => a + b)
Example 2: how to add all values of array together js
function addArrayNums(arr) {
let total = 0;
for (let i in arr) {
total += arr[i];
}
return total;
}