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

151
Views
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 answers
Answer question

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 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!