Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
How in Javascript to esxclude from an Array of Objects the items which contain specific pair of keys and values

I created this snippet to understand the issue

JSFiddle

I'm trying with a filter to exclude from an array all the items which have 2 specific keys as value === 'True' and team === 'Avengers'.

characters.filter(character => character.team !== 'Avengers' && character.value !== 'True');

My goal is to see as a result the following Object

[{
  name: "Flash",
  team: "Justice League",
  value: "False"
}, {
  name: "Deadpool",
  team: "X-Force",
  value: "False"
}]

As you see I should not see any item which has value === 'True' and also all the items which have team === 'Avengers'

But from the fiddles, you see that I'm having a wrong result and I don't know how to fix this as there are 2 items that should be excluded because they have value === true but are not as you see below

[{
  name: "Flash",
  team: "Justice League",
  value: "False"
}, {
  name: "Deadpool",
  team: "X-Force",
  value: "False"
}, {
  name: "Deadpool",
  team: "X-Force",
  value: "true"
}, {
  name: "Deadpool",
  team: "X-Force",
  value: "true"
}]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

String comparison is case-sensitive: a string that equals 'True' is not a string that equals 'true'.

You can fix this by including both in your filter condition:

character.team !== 'Avengers' && character.value !== 'True' && character.value !== 'true'

or (what I would probably do since it’s more durable) convert the string to upper-case before comparing for a case-insensitive comparison:

character.team.toUpperCase() !== 'AVENGERS' && character.value.toUpperCase() !== 'TRUE'

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!