The itemNumber variable stores the number. There are objects of the type cart.name1.price , cart.name2.price
How to put / substitute a variable in the place of a number? Maybe somehow it is necessary to screen?
cart.name+itemNumber+.price - swears to a point after +
cartobject does not explicitly match your needs. - D-sidevar name = 'name'+itemNumber; console.log(cart[name].price)var name = 'name'+itemNumber; console.log(cart[name].price)- mixname1:{ volume1:{ name:"111", volume:"0,9", price:"100" } }, name2:{ volume1:{ name:"222", volume:"0,9", price:"100" } }- KoteDoecarandcart:) The idea is correct, except that it makes no sense to explicitly specify keys in arrays, but I will assume that this is a reservation. - D-side