I have an array that needs to be populated without duplicate objects. However, I am constantly being sent back an array with the duplicate values. Can anyone tell me what I'm doing wrong here and how to fix it?
let holderArr = [
{
one: "A",
two: 2,
three: "String"
},
{
one: "B",
two: 2,
three: "String"
},
{
one: "A",
two: 2,
three: "String"
}]
function removeDuplicates(array){
let filteredArr = [];
return duplicateArray.filter((duplicate) => {
let id = [duplicate.one, duplicate.two].join("|");
if(filteredArr.indexOf(id) === -1){
filteredArr.push(id);
}
return out;
})
}
removeDuplicates(holderArr);