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

153
Views
matriz de filtros basada en múltiples condiciones

Me gustaría obtener el resultado de mi evento basado en el filtro.

 const filter = [ { type: 'type', value: ['In Person'] }, { type: 'city', value: ['Boston', 'Miami', 'New York'] }, ]; const events = [ { node: { city: 'Boston', type: 'In Person', name: 'Boston Party' } }, { node: { city: 'New Jersey', type: 'In Person', name: 'Hello Cookie' } }, { node: { city: 'Boston', type: 'Virtual', name: 'Sales Kick Off' } }, ]; const result = events.filter(o => Object .entries(o.node) .every(([k, v]) => filter .some(({ type, value }) => type === k && value.includes(v)),),) console.log(result)

Quiero el primer objeto de mis eventos porque el filtro contiene Boston y En persona. (Esta función funcionará si elimino el nombre de la clave en mis eventos). Cómo esta función puede devolver un resultado si tengo más clave y valor en mis eventos.

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

0

Podrías filtrar con filter .

 const filter = [{ type: 'type', value: ['In Person', 'Virtual'] }, { type: 'city', value: ['Boston', 'Miami', 'New York'] }], events = [{ node: { city: 'Boston', type: 'In Person', name: 'Boston Party' } }, { node: { city: 'New Jersey', type: 'In Person', name: 'Hello Cookie' } }, { node: { city: 'Boston', type: 'Virtual', name: 'Sales Kick Off' } }], result = events.filter(({ node }) => filter.every(({ type, value }) => !value.length || value.includes(node[type])) ); 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!