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

129
Views
Filter items based on value in nested array

How do you filter the results using javascript so any item that includes the tag 'help' are excluded from the results?

Here is the object I get back and what I have so far, but obviously doesn't work:

const data = {
  result: true,
  items: [{
      tags: ['typography', 'inspiration'],
      title: 'Typefaces Inspired by the Bauhaus',
    },
    {
      tags: ['layout', 'ratio', 'help'],
      title: 'Building a combined CSS-aspect-ratio-grid',
    },
  ]
}

const items = data.filter(data => data.tags !== 'help');

console.log(items)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

data.items.filter(item=> !item.tags.some(tag => tag === 'help'))

some will return true if any tag equals 'help', so use filter to select item when some returns false

about 4 years ago · Juan Pablo Isaza Report

0

You need to filter the data.items and use !some or !includes

Here is the data without the help in the items using includes

const data = {
  result: true,
  items: [{
      tags: ['typography', 'inspiration'],
      title: 'Typefaces Inspired by the Bauhaus',
    },
    {
      tags: ['layout', 'ratio', 'help'],
      title: 'Building a combined CSS-aspect-ratio-grid',
    },
  ]
}

data.items = data.items.filter(item => !item.tags.includes('help')); 

console.log(data)

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!