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

271
Views
search in array of array, and return results in one array

using the following array of arrays I need to make a search by letter, if it finds that element it should return in one array

example

const data= [[
      "car",
      "plane",
      "boat"
  ],
  [
      "cartago",
      "barcelona",
      "los angeles"
  ],
  [
      "headphone",
      "phone",
      "camera",
  ]
]

if match "ca" must return

[car, cartago, camera]

if match "ne" must return

[plane, headphone, phone]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

flat the array and filter it by checking if the substring is included in each element

const data= [[      "car",      "plane",      "boat"  ],  [      "cartago",      "barcelona",      "los angeles"  ],  [      "headphone",      "phone",      "camera",  ]]

let a = data.flat().filter(v => v.includes('ca'))
console.log(a)

let b = data.flat().filter(v => v.includes('ne'))
console.log(b)

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!