reduce to get a total, javascript code example
Example 1: javascript reduce sum
arrSum = function(arr){ return arr.reduce(function(a,b){ return a + b }, 0);}
Example 2: javascript reduce sum
let nums = [1, 2, 3];
nums.reduce((curr, next) => curr + next);