I have an array that looks like this:
data = [
{name:'Tom', a:1, b:1, c:0},
{name:'Sam', a:0, b:1, c:1},
{name:'Tom', a:0, b:0, c:1},
{name:'Sam', a:1, b:2, c:1},
{name: 'Jack', a:1, b:2, c:0}
]
My goal is to calculate the total for each property of objects with the same name and then remove any duplicates:
result = [
{name:'Tom', a:1, b:1, c:1},
{name:'Sam', a:1, b:3, c:2},
{name: 'Jack', a:1, b:2, c:0}
]
Is there a way to achieve this using only pure JavaScript?