Puzzling javascript functionality

The source exercise

above the let inStock variable successfully determines whether or not the product(s) being ordered are in stock, or not. but how is this possible? as far as I can see out of every possible way this could operate none should work. how does inStock actually behave, and how is it successful? bellow ive also included what an order looks like.

you understand the every method? Here is the documentation:


the every method returns a Boolean value, true if all the elements pass the test, true is returned, else false is returned

the first item is ['sunglasses', 1], so item[0] will give use 'sunglasses', which we then use as key to get the value (stock amount) of inventory. Which gives use zero

item[1] gives 1 (customer wants to buy 1 pair of sunglasses), so then the final comparison becomes:

0 >= 1

which is false.