I have an two arrays of products called cart and stock. Let's say there are 5 products a to e.
Stock might look like
stock[a] = 5, stock[b] = 5...
etc etc
and cart might look like
cart[a] = 2, cart[b] = 0...
I am trying to do something like
for (var product in cart){
if(cart[product] > 0){
cart[product] = stock[product]
}
But stock[product] always returns 0. How can i make it so that I can use the same variable product to access products within both stock and cart?
I tried something like
for (var product in cart && var product in stock)
but it doesnt work.
Is there any other alternative?