Promises in the Pancake Business 🥞🥞
Sat Nov 11 2023 10:45:30 GMT+0000 (Coordinated Universal Time)
Saved by
@temycodes
let stocks = {
PancakeIngredients: ["flour", "eggs 🥚", "sugar", "milk🥛", "butter"],
liquid: ["water 🥛", "coffee ☕", "wine🍷"],
holder: ["frying pan 🍳"],
toppings: ["sauce 🥫"],
};
let orderPancake = (time, work) => { return new Promise((resolve, reject) => {
if (is_pancake_shop_open) {
setTimeout(() => {
resolve(work());
}, time);
} else {
reject(console.log("pancake shop closed"));
}
}); };
orderPancake(2000, () =>
console.log(
`cool! pancake shop is open, let's add some ${stocks.toppings[0]} to give it some unique taste`
)
);
content_copyCOPY
Comments