I am working with an array that contains numbers of array objects, and I need to merge these arrays into a single array with unique values for content
and the sum of values for total
as shown in the desired result below. Any assistance would be greatly appreciated.
Result Set
[
[
{
content: 'Aqurie',
total: 5
},
{
content: 'Mail function',
total: 4
}
],
[
{
content: 'Aqurie',
total: 4
},
{
content: 'Mail function',
total: 10
}
]
]
Desired Result
[
{
content: 'Aqurie',
total: 9
},
{
content: 'Mail function',
total: 14
}
]
My current approach to achieving this is:
var transformed = arr.reduce(function(a, b){ return a.concat(b); });
console.log(transformed);