Before people think this is the same as all these other answers on Stack Overflow regarding removing duplicates can you please look at what is returned as opposed to what I am looking to do.
I want to remove all elements that occur more than once. I have tried the following:
const a = ['Ronaldo', 'Pele', 'Maradona', 'Messi', 'Pele'];
const uniqueArray = a.filter(function(item, pos) {
return a.indexOf(item) == pos;
})
console.log(uniqueArray)
I want my uniqueArray to be
['Ronaldo', 'Maradona', 'Messi'];