I am having problems with my code because I think it is not flexible if a new array is inserted in my nested array I will not consider the new array. The important thing is how do I access to the first element, then second and so on at the same time of each array.
Here is an Example:
const nestedArr = [
[
"COCA - COLA ORIGINAL 355 ML VIDRIO RET",
"COCA - COLA ORIGINAL 600 ML PET NR",
"COCA - COLA ORIGINAL 2.5 LT RET"],
[
"$176.02",
"$100.00",
"$130.00"
],
[
"10",
"3",
"15"
]
]
const ordersObj = []
for (let i=0; i< nestedArr[0].length; i++){
var name = orderArr[0][i];
var price = Number(orderArr[1][i].replace("$",""));
var qty = orderArr[2][i];
var amount = price * qty;
ordersObj.push({name,price,qty,amount})
}
What I would like to do is to avoid to put 0,1,2 to set the position of which nested array I want to access, I want to run a loop or change my code so that 0,1,2 are not hard coded.
Regards