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

155
Views
How to check an eitem is present in which array in javascript?

I have two 3 unique arrays:

const a =["b","c","d"];
const b = ["ab","cd","ef"]
const c = ["abc", "cde","fgh"]

with array.includes("ab") we can findout that it is in b array. but If we take abc and want to search which arrayname it is present in?

How can I do that

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

0

Here's one way

const a =["b","c","d"];
const b = ["ab","cd","ef"]
const c = ["abc", "cde","fgh"]

const find = (needle, haystack) => Object.entries(haystack).find(([k,v])=>v.includes(needle))[0];
console.log(find('ab', {a, b, c}))
console.log(find('abc', {a, b, c}))

of course, this returns a string, which is almost useless to then access the array in a meaningful way - but this does answer the question

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!