(As per advice to be more precise and clear in asking questions I edited this post for that purpose)
Hello Everyone,
I need help understanding this specific code:
stocks[item[0]].inventory >= item[1]
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 navigate thru the properties of an object in this way? 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])
})