sun of value array js code example
Example 1: summation js
const summation = (n) => (n * (n + 1)) / 2;
Example 2: sum of all elements in array javascript
arrSum = function(arr){ return arr.reduce(function(a,b){ return a + b }, 0);}
const summation = (n) => (n * (n + 1)) / 2;
arrSum = function(arr){ return arr.reduce(function(a,b){ return a + b }, 0);}