PROBLEM
I have an array like this one:
[
{
cardId: "4908r920-2394930-3302-222",
power: 3
},
{
cardId: "4908r920-2394930-3302-222",
power: 10
},
{
cardId: "6666640-92011-3302-888",
power: 932
},
{
cardId: "4908r920-2394930-3302-222",
power: 5
},
{
cardId: "6666640-92011-3302-888",
power: 9
}
]
As you can see, in this array there are two different cards:
The card which id is "4908r920-2394930-3302-222" and the other one which id is "6666640-92011-3302-888"
These cards have a different power, but they are duplicated in the array by the field cardId.
QUESTION
I need to remove the lower power repeated cards, I mean, the final array has to be as follows:
[
{
cardId: "4908r920-2394930-3302-222",
power: 10
},
{
cardId: "6666640-92011-3302-888",
power: 932
}
]
Any ideas? I would appreciate if the solution was in +ES6.
Thank you.