Skip to content

Commit eab8b1b

Browse files
committed
create starter file for video 71
1 parent 8ad0d53 commit eab8b1b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title>Async Await</title>
8+
<link rel="stylesheet" href="../base.css">
9+
</head>
10+
11+
<body>
12+
<script>
13+
function wait(ms = 0) {
14+
return new Promise((resolve) => {
15+
setTimeout(resolve, ms);
16+
})
17+
}
18+
19+
function makePizza(toppings = []) {
20+
return new Promise(function (resolve, reject) {
21+
// reject if people try with pineapple
22+
if (toppings.includes('pineapple')) {
23+
reject('Seriously? Get out 🍍');
24+
}
25+
const amountOfTimeToBake = 500 + (toppings.length * 200);
26+
// wait 1 second for the pizza to cook:
27+
setTimeout(function () {
28+
// when you are ready, you can resolve this promise
29+
resolve(`Here is your pizza 🍕 with the toppings ${toppings.join(' ')}`);
30+
}, amountOfTimeToBake);
31+
// if something went wrong, we can reject this promise;
32+
});
33+
}
34+
35+
</script>
36+
</body>
37+
38+
</html>

0 commit comments

Comments
 (0)