-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtask2.js
More file actions
35 lines (23 loc) · 919 Bytes
/
task2.js
File metadata and controls
35 lines (23 loc) · 919 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
import { sleep } from './promises.js'
/*
Create a function that prints "Done" after 2 seconds to the console.
- Right now use the sleep function to accomplish this, it is already provided for your convenience.
The sleep function returns a Promise. It fulfills after the given amount of milliseconds, so this
function basically waits N milliseconds asynchronously.
syntax: sleep(waitingTime: number): Promise
example: sleep(5000)
- Use the `then` syntax.
Goal: Practice the fulfilled then syntax without return value.
Hints:
- https://javascript.info/promise-basics#consumers-then-catch
Questions:
- What is a Promise?
- What properties / methods it has?
- How the control flow looks like? What will be executed when?
- Where have you used promises recently?
- What is the difference between a fetch call and this sleep call?
*/
const task = () => {
// Your code goes here
}
task()