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
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