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

125
Views
Cómo encontrar el índice de valor de tamaño múltiple basado en el valor

datos = { boxNoTo: 1, boxNoFrom: 1, tamaño: 'M', }

matriz = [{ tamaño: 'M', },{ tamaño: 'M', },{ tamaño: 'S,M,L,XS', boxNoTo: 1, boxNoFrom: 1, país: 'CA', nombre: 'José'}]

lo que hice es asi

 const INDEX = array.findIndex((x) => { if (x.size.split(',').length > 0) { return ( x.size.split(',').filter((y) => y === data['size'])[0] === data['size'] && x.boxNoFrom === data['boxNoFrom'] && x.boxNoTo === data.boxNoTo ); } else { return ( x.size === data['size'] && x.boxNoFrom === data['boxNoFrom'] && x.boxNoTo === data.boxNoTo ); } });

Lo que estoy tratando de hacer es obtener el índice de

 { size: 'S,M,L,XS', boxNoTo: 1, boxNoFrom: 1, country: 'CA', name: 'Josh' }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Podrías intentar algo como esto:

 const data = { boxNoTo: 1, boxNoFrom: 1, size: 'M', }; const array = [{ size: 'M', },{ size: 'M', },{ size: 'S,M,L,XS', boxNoTo: 1, boxNoFrom: 1, country: 'CA', name: 'Josh' }]; const { size, ...rest } = data; const index = array.findIndex(item => item.size.split(',').includes(size) && Object.keys(rest).every(key => item[key] === rest[key]) ); console.log(index);

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!