Module.exports

There is a library.js in the Javascript promises, at the end of the code, there is a module.exports.
the code link is here javascript promises

the original code is as below:

const inventory = {
sunglasses: 1900,
pants: 1088,
bags: 1344
};

const checkInventory = (order) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
let inStock = order.every(item => inventory[item[0]] >= item[1]);
if (inStock) {
resolve(Thank you. Your order was successful.);
} else {
reject(We're sorry. Your order could not be completed because some items are sold out.);
}
}, 1000);
})
};

module.exports = { checkInventory };

I do not know why in the module exports there is curly braces { }, I think there should now curly braces in module exports, but there should curly braces in named export.

anyone who can explain please? thanks

Hi there! Somebody asked the same question, take a look:

JavaScript Promises: 6/11 - Why is checkInventory exported, and imported, with curly braces around the variable

Also, I googled “curly braces module.exports” and there were a lot of stackoverflow articles, you might want to read some and see if that helps :+1:

2 Likes