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

127
Vistas
Sintaxis de JavaScript declarar objeto dentro de la función

Escribí un código:

 const search = (what, arr) => arr.filter((el) => (onde(what,el).tag).includes((onde(what,el).input)));

pero llama a la función onde() , dos veces.

Pero no es necesario.

Cómo configurar part = onde(what,el);

dentro const search ?

por lo que solo se puede llamar una vez, como part.tag y part.input

 const search = (what, arr) => arr.filter((el) => (onde(what,el).tag).includes((onde(what,el).input))); function exibe(el, index, array) {console.log(index+" = " + el.name +" " + el.value+" " + el.other);} function onde(what,where) { array1=[]; tags =what.split(':')[0]; tag =tags.split(','); tag.forEach(element => { array1.push(where[element]);}); array['tag']=array1.join(' ').toLowerCase(); array['input']=what.split(':')[1].toLowerCase(); return array; } var array = [ { name:"string 1", value:"this A", other: "that 10" }, { name:"string 2 this", value:"those B", other: "that 20" }, { name:"string 3", value:"this C", other: "that 30" } ]; const serached = search("name,value:this",array); if (serached) { serached.forEach(exibe); } else { console.log('No result found'); }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Guárdelo en una variable primero.

 const search = (what, arr) => arr.filter((el) => { const { tag, input } = onde(what, el); return tag.includes(input); });

o

 const search = (what, arr) => arr.filter((el) => { const result = onde(what, el); return result.tag.includes(result.input); });
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