Skip to content

Commit 631bb34

Browse files
committed
10 coffee machine problem
1 parent c636aad commit 631bb34

File tree

1 file changed

+17
-0
lines changed
  • Problem Solutions/010 The Coffee Machine

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const brewCoffee = async (type)=>{
2+
return new Promise((resolve, reject)=>{
3+
const randomDelay = Math.floor(Math.random() * (5000 - 1000 + 1)) + 1000;
4+
setTimeout(()=>{
5+
resolve(`Here is your ${type} coffee`)
6+
}, randomDelay)
7+
})
8+
}
9+
10+
(async () => {
11+
try {
12+
const result = await brewCoffee("Latte");
13+
console.log(result);
14+
} catch (error) {
15+
console.error(error);
16+
}
17+
})();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy