How can I make it so this function returns all the duplicates and not only the first it finds? Right now this returns only Sweden but I would like it to return [Sweden,Denmark] since they both have duplicate values?
const TestArray = [{
"place": "Sweden",
"value": 5
},
{
"place": "Sweden",
"value": 15
},
{
"place": "Norway",
"value": 5
},
{
"place": "Denmark",
"value": 15
},
{
"place": "Sweden",
"value": 5
},
{
"place": "Denmark",
"value": 5
}
]
const foundDuplicateName = TestArray.find((nnn, index) => {
return TestArray.find((x, ind) => x.place === nnn.place && index !== ind)
})
console.log(foundDuplicateName)