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

173
Views
filter objects with same ids from two separate arrays of objects in javascript

Array One:

Cuisines in Profile      =======>>  [{"id": 2, "name": "Indian"}, {"id": 4, "name": "Mexican"}, {"id": 5, "name": "Mediterranean"}, {"id": 6, "name": "Middle Eastern"}, {"id": 7, "name": "Chinese"}, {"id": 8, "name": "Japanese"}, {"id": 9, "name": "Italian"}, {"id": 10, "name": "Pick for Me"}, {"id": 16, "name": "BBQ"}]

Array Two:

Selected Cuisines        =======>>  [{"cuisine_id": 6, "id": 1260}, {"cuisine_id": 16, "id": 1262}, {"cuisine_id": 8, "id": 1268}, {"cuisine_id": 10, "id": 1269}]

Now I want to get a new filtered objects from Array one where id from Array one and cuisine_id from Array two are the same

Expected Output:

[{"id": 6, "name": "Middle Eastern"}, {"id": 8, "name": "Japanese"}, {"id": 10, "name": "Pick for Me"}, {"id": 16, "name": "BBQ"}]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const cuisines = [
  { id: 2, name: 'Indian' },
  { id: 4, name: 'Mexican' },
  { id: 5, name: 'Mediterranean' },
  { id: 6, name: 'Middle Eastern' },
  { id: 7, name: 'Chinese' },
  { id: 8, name: 'Japanese' },
  { id: 9, name: 'Italian' },
  { id: 10, name: 'Pick for Me' },
  { id: 16, name: 'BBQ' },
];
const selected = [
  { cuisine_id: 6, id: 1260 },
  { cuisine_id: 16, id: 1262 },
  { cuisine_id: 8, id: 1268 },
  { cuisine_id: 10, id: 1269 },
];
const result = cuisines.filter(c => selected.some(s => s.cuisine_id === c.id));
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!