Suppose we have an array of objects like :
[ { LeadId: AABB , Phone: 1234 , } ,
{ LeadId: ABCD , Phone: 5678 , } ,
{ LeadId: EERR , Phone: 1234 , } ,
{ LeadId: FFGG , Phone: 5678 , } ]
And an array of phone numbers :
[ 1234 , 5678 , 6565 ]
I want to remove the first occurrence of every phone number in the first list , hence the result would be :
{ LeadId: EERR , Phone: 1234 , } ,
{ LeadId: FFGG , Phone: 5678 , }
Assume that leadsToInsert
is the array that we need to remove occurrences from
and phoneNumbers
is the array of phone numbers
I've tried with Underscore :
const leftOvers = _.without(
leadsToInsert,
_.find(leadsToInsert, {
Phone: phoneNumbers
})
);
When I run this piece of code all the objects in leadsToInsert
remains and nothing is filtered.
When did I go wrong ?