Remove entire key when matched with matched array values

I am new to react, I have an object and an array, I want to get details of unmatched items from the object when compared with array values. I tried but shows all the data when consol.log. here is my code

var content:[
    0:{id:20, name:'Jack Daniel'}
    1:{id:21, name:'Sophie McDonald'}
    2:{id:22, name:'Jason Thomas'}
    3:{id:23, name:'Chris Williams'}
]

var filter:[Sophie McDonald, Chris Williams]

filterValues = content.filter(item=> {
            
    for(var i = 0;i<filter.length;i++) {
        if (item.name === filtered[i])
        {
            return item              
        }       
     } 
});
console.log(filteredValues)
  // returns  0:{id:21, name:'Sophie McDonald'}
  //          1:{id:23, name:'Chris Williams'}

But I need unmatched results,

filterValues = content.filter(item=> {
            
    for(var i = 0;i<filter.length;i++) {
        if (item.name !== filtered[i])
        {
            return item              
        }       
     } 
});
console.log(filteredValues)
// returns  0:{id:20, name:'Jack Daniel'}
//          1:{id:21, name:'Sophie McDonald'}
//          2:{id:22, name:'Jason Thomas'}
//          3:{id:23, name:'Chris Williams'}

Result must be

 0:{id:20, name:'Jack Daniel'}
 1:{id:22, name:'Jason Thomas'}

92 thoughts on “Remove entire key when matched with matched array values”

  1. i need a loan shark, i need a quick loan no credit check. need a loan but my credit is bad need loan now i own my home outright and need a loan i need a loan with bad crediti need a loan fast, cash payday loans bad credit, cash advance online, cash advances, serve u cash payday loans. Money management is typically viewed commerce, designed for companies.

    Reply
  2. Excellent post. Keep writing such kind of info on your blog.
    Im really impressed by your blog.
    Hello there, You’ve performed an incredible job. I’ll definitely digg it and
    individually suggest to my friends. I am confident they
    will be benefited from this site.

    Reply
  3. Fantastic site. Lots of useful information here. I am sending
    it to several buddies ans also sharing in delicious.
    And certainly, thanks for your sweat!

    Reply
  4. naturally like your web site however you have to take a look at the spelling on several of your posts.

    A number of them are rife with spelling issues and I to find it very bothersome to tell the reality then again I’ll definitely come back again.

    Reply

Leave a Comment