I have a object array that has a value like this
[
{
username: 'Goku',
hero: 'superman',
power: 'laser',
isMasked: false
},
{
username: 'Gohan',
hero: 'batman',
power: 'brain',
isMasked: true
},
{
username: 'Goten',
hero: 'cyclops',
power: 'laser',
isMasked: true
},
{
username: 'picollo',
hero: 'superman',
power: 'streangth',
isMasked: false
},
{
username: 'bulma',
hero: 'batman',
power: 'rich',
isMasked: true
},
{
username: 'brolly',
hero: 'jin',
power: 'laser',
isMasked: false
}
]
As you can see, the array contains a json that has a different heroes, some of them have a same power, but the problem is, some user had a same heroes, what I want to do is that I want to remove those objects inside my array that contains a same heroes as others, so that the output will be
[
{
username: 'Goku',
hero: 'superman',
power: 'laser',
isMasked: false
},
{
username: 'Gohan',
hero: 'batman',
power: 'brain',
isMasked: true
},
{
username: 'Goten',
hero: 'cyclops',
power: 'laser',
isMasked: true
},
{
username: 'brolly',
hero: 'jin',
power: 'laser',
isMasked: false
}
]
As you can see, users with the same hero as another is removed, and the array only contains objects with unique heroes, I'm using reactjs as my JavaScript framework, how can I do that?