I try to use .finally in the program but it giving me error, i don’t understand why ?
It’s hard to know from the screenshot but are you missing a closing parenthesis for the first then
at the very end? (I’m guessing it’s on line 23 if it’s there…).
this is the code
const inventory = {
sunglasses: 1900,
pants: 1088,
bags: 1344
};
// Write your code below:
const myExecutor = (resolve, reject) => {
if(inventory.sunglasses > 0) {
resolve('Sunglasses order processed.');
} else {
reject('That item is sold out.');
}
}
const orderPromise = new Promise(myExecutor);
orderPromise.then(resolve => {
console.log(resolve);
}).catch(e => {
console.log(e);
}).finally(() => {
console.log("Promise complete!")
});