sum built in function javascript 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);}