So I’ve got this cartItems object which lists my cart items. Each cart item has a ‘name’ and ‘quantity’ property.
I want to create an object like this…
The object you have pointed out above will lead to an error if I am not mistaken unless you change it to an array. That is if you don’t want to add properties, so that it becomes:
Are you creating the above object from scratch or from another dataset? If it is from scratch why have you chosen to go with an object? It appears an array of objects would be the best option.