How to make a dynamic array of objects?

Hi everybody!

Please tell me how to make a dynamic array of objects?
{
 "list" : [
{
 "name": "товар1",
 "price": 15000,
 "quantity": 7
},
{
 "name": "товар2",
 "price": 25500,
 quantity: 2
},
{
 "name": "товар3",
 "price": 5000,
 quantity: 5
 } 
]
}


of the following object

{
 "name": "товар1",
 "price": 15000,
 "quantity": 7
},
March 20th 20 at 11:39
1 answer
March 20th 20 at 11:41
Solution
@florine40, suppose that your shopping cart is stored in the cart variable contains an array of goods:
[
{
 "name": "товар1",
 "price": 15000,
 "quantity": 7
},
{
 "name": "товар2",
 "price": 25500,
 quantity: 2
}
]

then:
// generated data to send
const sendData = {
 list: cart
};


if you do not have the array of user-selected products, then it is not clear what you mean by the word basket.
Thank you, and I was working ) - anjali25 commented on March 20th 20 at 11:44
@florine40, but not for that. Always happy to help, contact us. And don't forget to say thanks to those who noted in the comments, without them I would have to guess what you want to achieve) - cristal29 commented on March 20th 20 at 11:47

Find more questions by tags JavaScript