I'm working on a prototype with shopping cart functionality. To keep track of what's in the cart, I use an array. As the user adds products to the cart, I simply add an object to the array that contains the name and price of the item, which will feed the cart's display and price calculations.
When the user adds more than one of the same product type to the cart, I just add another object with name and price. So, in practice, it's possible that multiple objects appear in the cart array that are identical.
My question is – how would I go about removing an item from the cart array, without knowing its index, and with the possibility that multiple items in the array may have the same value?