Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda