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

123
Views
Filtrar dentro de una matriz de dictados por clave

Tengo esa matriz de dict:

 arrayDict: [ { Description: "Dict 0" Category: [ 'First', 'Both', ], }, { Description: "Dict 1", Category: [ 'Second', 'Both', ], }, ]

me gustaría filtrar dentro de esa matriz por Categoría. Recibiré una categoría y necesito filtrar. Si recibo "Ambos", necesito devolver "Dict 1" y "Dict 0". si recibo "Segundo", devuelvo solo "Dict 1".

¿Cómo puedo hacer eso?

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

0

Puede lograr su objetivo utilizando el método de filtro , como este:

 const arrayDict = [ { Description: "Dict 0", Category: [ 'First', 'Both', ], }, { Description: "Dict 1", Category: [ 'Second', 'Both', ], }, ]; const filterDict = (key)=> arrayDict.filter(({Category}) => Category.includes(key)) console.log('First:',filterDict('First')); console.log('Second:',filterDict('Second')); console.log('Both:',filterDict('Both'));

about 4 years ago · Juan Pablo Isaza Report

0

algo como esto:

 arrayDict.filter((item)=> item.Category.includes('Both'))
about 4 years ago · Juan Pablo Isaza Report

0

simplemente puede usar el filter() : función de orden superior proporcionada por JS.

 var arrayDict = [ { Description: "Dict 0", Category : [ 'First', 'Both', ] }, { Description: "Dict 1", Category : [ 'Second', 'Both', ], }, ] let input = 'Both'; let filteredData = arrayDict.filter((elm) => { return elm.Category.includes(input) }) console.log(filteredData);
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!