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

152
Vistas
Filter array of objects by array strings and match with substrings of the object
Actual Code
//return arrayOfObjects.filter((object) => searchTags.every((tag) => Object.values(object).includes(tag)))

array of objects =

let searchTags= ['damiencbib','ADLs'];
    {
        "key": "ACCOR02a",
        "type": "techreport",
        "AUTHOR": "ACCORD",
        "INSTITUTION": "ACCORD",
        "KEYWORDS": "damiencbib adl",
        "MONTH": "June",
        "TITLE": "'Etat de l'art sur les Langages de Description d'Architecture (ADLs)",
        "URL": "http://projects.infres.enst.fr/accord/",
        "YEAR": "2002",
        "BDSK-URL-1": "http://projects.infres.enst.fr/accord/"
    },
    {
        "key": "ACM94b",
        "type": "article",
        "AUTHOR": "ACM",
        "INSTITUTION": "ACM",
        "JOURNAL": "Communications of the ACM",
        "KEYWORDS": "scglib",
        "MONTH": "May",
        "NUMBER": "5",
        "TITLE": "Reverse Engineering",
        "VOLUME": "37",
        "YEAR": "1994"
    }

Expected result is only the first object in the array because it contains both 'damiencbib','ADLs' inside. Something is not working as expected for me, I was thinking to use Regex. Thank you in advance.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to check some value as well.

const
    searchTags = ['damiencbib', 'ADLs'],
    data = [{ key: "ACCOR02a", type: "techreport", AUTHOR: "ACCORD", INSTITUTION: "ACCORD", KEYWORDS: "damiencbib adl", MONTH: "June", TITLE: "'Etat de l'art sur les Langages de Description d'Architecture (ADLs)", URL: "http://projects.infres.enst.fr/accord/", YEAR: "2002", "BDSK-URL-1": "http://projects.infres.enst.fr/accord/" }, { key: "ACM94b", type: "article", AUTHOR: "ACM", INSTITUTION: "ACM", JOURNAL: "Communications of the ACM", KEYWORDS: "scglib", MONTH: "May", NUMBER: "5", TITLE: "Reverse Engineering", VOLUME: "37", YEAR: "1994" }],
    result = data.filter(object => searchTags.every(tag => Object
        .values(object)
        .some(s => s.includes(tag))
    ));

console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }

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