Next, I'm a designer and I'm learning javascript slowly. One of the things that I have the most difficulties, are objects and arrays, so I'm focusing on it now. I have an array with 4 objects as the following code.
var players = [{
name: "Batman",
id: "1",
points: 10
},
{
name: "Superman",
id: "2",
points: 10
},
{
name: "Batman",
id: "1",
points: 10
},
{
name: "Superman",
id: "2",
points: 5
}
];
What I need: return objects with the same ids and points added, resulting in 2 objects.
What logic do I use to solve this problem? How to join the objects with the same id and add the points of each? I already managed to do with only 1 object, but was comparing with the id. If I had a much larger array, it would be almost unfeasible to compare one by one. I want to understand the logic applied in this context.