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

145
Views
buscar en una matriz en una serie de objetos por un solo carácter

Cómo buscar en una matriz dentro de la matriz del objeto por un solo carácter

 const arr = [{ x: 1, tags: ["tag1", "taf", "ee", "xx"] },{ x: 3, tags: ["ta", "e", "xx"] }]; const fResult = arr.filter((res) => res.tags().includes("tag1"));

esto devolverá el valor si ingresamos una palabra tag1 completa, no solo "t" o "ta"

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Si desea hacer coincidir que el valor comienza con él, entonces desea usar some()

 const filterIt = (arr, text) => arr.filter( (res) => res.tags.some( val => val.startsWith(text) ) ); const arr = [{ x: 1, tags: ["tag1", "taf", "ee", "xx"] }, { x: 3, tags: ["ta", "e", "xx"] }]; console.log("t", filterIt(arr, "t")); console.log("ta", filterIt(arr, "ta")); console.log("tag", filterIt(arr, "tag"));

about 4 years ago · Juan Pablo Isaza Report

0

finalmente descubrí esta solución simple

al convertir la matriz de etiquetas en una cadena, luego verificar al incluir es resolver todo

 const arr = [{ x: 1, tags: ["tag1", "taf", "ee", "xx"] },{ x: 3, tags: ["ta", "e", "xx"] }];

aquí está la solución const fResult = arr.filter((res) => res.tags.toString().includes("tag1"));

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!