I'd like to Sum all objects by their key name using loop. The key "id" will be delete
var arr = [{id:1, "my color":1,"my fruit":4},{id:2,"my color":2,"my fruit":4},etc];
var merged = arr.reduce(function(previousValue, currentValue) {
return {
"my fruit": previousValue["my fruit"] + currentValue["my fruit"],
"my color": previousValue["my color"] + currentValue["my color"],
etc:...
}
});
I'd like this result
result = [{"my color":3},{"my fruit":8},etc];