Skip to content

Commit 923eb60

Browse files
authored
Create 2621-sleep.js
1 parent c071774 commit 923eb60

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

javascript/2621-sleep.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {number} millis
3+
* @return {Promise}
4+
*/
5+
async function sleep(millis) {
6+
return new Promise(resolve => setTimeout(() => resolve("Completed!"), millis));
7+
}
8+
9+
/**
10+
* let t = Date.now()
11+
* sleep(100).then(() => console.log(Date.now() - t)) // 100
12+
*/

0 commit comments

Comments
 (0)