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

127
Views
¿Cómo encontrar el índice con 2 condiciones?

Tengo 2 matrices.

 Size = ['Size 0', 'Size 2', 'Size 3'] Cart = ['1', '2', '3'] // 1, 2, 3 = product id

¿Cómo obtener la posición de la matriz con size = 'Size 0' y el Cart = '2' ?

Lo intenté

 let id = req.params.id; // id = product_id let size = req.body.size; k = req.session.size.findIndex(function(a){ req.session.cart.findIndex(function(c){ return a == size && c == id; }) });

pero no funciona

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

0

Tiene dos matrices separadas, por lo que deberá calcular dos índices separados: uno para Size y otro para Cart .

 let productId = req.params.id; let size = req.body.size; const sizeIndex = req.session.size.findIndex(function(testSize){ return testSize === size; }); // sizeIndex is valid index as long as it isn't -1 const idIndex = req.session.cart.findIndex(function(testId){ return testId === productId; }); // idIndex is valid index as long as it isn't -1
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!