I have the following array:
[
{
"value":"ETH",
"label":"ETH"
},
{
"value":"LTC",
"label":"LTC"
},
{
"value":"ETH",
"label":"ETH"
}
]
As you can see, there are duplicate values. What is the best way to remove them?
I have tried to do these 2 forms, but without success:
let values = [
{
"value":"ETH",
"label":"ETH"
},
{
"value":"LTC",
"label":"LTC"
},
{
"value":"ETH",
"label":"ETH"
}
]
console.log(values.filter((elem, index, self) => index === self.indexOf(elem)))
console.log([... new Set(values)])
I did not understand why the set did not work, as it tries to create a list of unique values.