Array Sum Javascript
const arr = [1, 2, 3, 4];
const sum = arr.reduce((a, b) => a + b, 0);
// sum = 10
Marton
const arr = [1, 2, 3, 4];
const sum = arr.reduce((a, b) => a + b, 0);
// sum = 10
[1, 2, 3, 4].reduce((a, b) => a + b, 0)
// Output: 10
const sum = arr => arr.reduce((a, b) => a + b, 0);
arrSum = function(arr){ return arr.reduce(function(a,b){ return a + b }, 0);}
[1, 2, 3, 4].reduce((a, b) => a + b, 0)