-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy path10_solve.html
More file actions
37 lines (34 loc) · 977 Bytes
/
10_solve.html
File metadata and controls
37 lines (34 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button class="Espresso">Brew Espresso</button>
<script>
let coffeeDelay = {
"Espresso": 1732,
"Latte": 892,
"Cappuccino": 2054,
"Americano": 1500,
"Mocha": 627,
"Macchiato": 2345,
"Flat White": 1045
}
async function brewCoffee(coffee) {
return await new Promise(resolve => {
delay = coffeeDelay[coffee];
document.querySelector(`.${coffee}`).innerHTML = "Brewing...";
setTimeout(() => {
resolve(coffee + " brewed");
}, delay);
})
}
document.querySelector(".Espresso").addEventListener("click", () => {
brewCoffee("Espresso").then(resolve => document.querySelector(".Espresso").innerHTML = resolve);
})
</script>
</body>
</html>