-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy path08_solve.html
More file actions
30 lines (26 loc) · 750 Bytes
/
08_solve.html
File metadata and controls
30 lines (26 loc) · 750 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
<!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>
<script>
let numbers = [1, 23, 12, 33, 213, 46, 34];
const multiply = async (numbers) => {
return await Promise.all(numbers.map(num =>
new Promise(resolve => setTimeout(() => {
resolve(num * 2)
}, 500))
))
}
multiply(numbers).then(result => console.log(result))
// alternate
// (async () => {
// const result = await asyncDoubleArray([1, 2, 3, 4, 5]);
// console.log(result); // Output: [2, 4, 6, 8, 10] after 500ms
// })();
</script>
</body>
</html>