I want to perform the sum operation on each subarray using javascript using forEach,map,reduce function, so that ultimately my output should look like:
sum = [8,13,22]
but I am not getting the desired output. Please assist where I am going wrong.Thanks.
var Data = [{"a":1,"b":2,"c":5},{"a":3,"b":4,"c":6},{"a":6,"b":7,"c":9}];
var newArr = [];
Data.forEach(function(item) {
item = item.reduce(function(a, b) {
return a + b;
});
newArr.push([item]);
});
console.log(newArr);