JavaScript promises 6/11: Why only exporting the checkInventory function?

I do not understand why only the checkInventory function is exported in library.js. why not the object inventory as well? is it because inventory is used within the function checkInventory?

Here’s the link to the exercise

Well, you have to look at it from a real life practical point of view. In this case we have an app on someone’s phone and an inventory at the company.

The object inventory may be huge, not just containing sunglasses and pants of one type but many more products, sizes, colors etc. You don’t want to export that whole list every time someone orders a product (this costs time, memory etc). Besides that the inventory is continuously changing. So therefore the inventory is kept separate from the app user. And only the check function is exported.

4 Likes