I know we can sum the array elements using reduce() but what if we have an array of arrays. For eg:
var result=[10,20,30];
result.reduce((a, b) => a + b)
it will return 60
but if we have
result=[
[10,20,30],
[20,30,40],
[60,70,80]
]
console.log(result);
how can we get the final result as result=[60,90,210] using reduce?
resultarray. In that case, do:result.forEach(function(d, i, arr) { arr[i] = d.reduce((a, b) => a + b, 0);});