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

143
Views
How to get objects by searching the array content

I have this object

let obj = [
   {name: 'title 1', values:['test 1', 'test 2']},
   {name: 'title 2' values: ['test 3', 'test 4']}
]

I want to search for values = 'test 3' and it will return objects contaning that skills ouput: {name: 'title 2' values: ['test 3', 'test 4']}

I have tried searching like obj.find(c=> c.skills), iteration etc. but it only works not inside the array of objects.

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

0

I'd use filer to apply a condition on values:

 let obj = [
   {name: 'title 1', values:['test 1', 'test 2']},
   {name: 'title 2', values: ['test 3', 'test 4']}
];

const result = obj.filter(o => o.values.includes('test 3'));

console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

You could find the object by looking into the array with Array#includes.

const
    objects = [{ name: 'title 1', values: ['test 1', 'test 2'] }, { name: 'title 2', values: ['test 3', 'test 4'] }],
    value = 'test 3',
    result = objects.find(({ values }) => values.includes(value));

console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

Use filter:

let obj = [{
  name: 'title 1',
  values: ['test 1', 'test 2']
}, {
  name: 'title 2',
  values: ['test 3', 'test 4']
}];

let skill = 'test 3';
let result = obj.filter(c => c.values.includes(skill));

console.log(result);

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!