I need help understanding this specific code:
stocks[item[0]].inventory
How did the code above accessed or pin-pointed what needed to be pin-pointed using this “[item[0]]
” on the stocks object
? Can you please teach me how to pin-point thru the properties of an object in this way? What keywords or what can I search in Google to see more explanation for this? WHAT and HOW the logic works on this? Thank you!
const stocks = {
Mangoes : {
inventory: 300,
cost: 2.00
},
'Star Apple' : {
inventory: 400,
cost: 3.00
},
'Jack Fruit' : {
inventory: 300,
cost: 4.00
},
Apples : 100,
cost: 6.00
}
const fruits = {
items : [['Mangoes', 50],['Apples', 30]]
}
fruits.items.every((item) => {
console.log(stocks[item[0]].inventory >= item[1])
})
Well, I can used Object.entries, keys, or values to alternatively do that but I can'treally seem to understand how the logic of this code works stocks[item[0]].inventory