mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-09 15:59:06 +01:00
problems(js): add “2621. Sleep”
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
ac8a1720ef
commit
d5c96c6a21
1 changed files with 13 additions and 0 deletions
13
problems/sleep.js
Normal file
13
problems/sleep.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* @param {number} millis
|
||||
*/
|
||||
async function sleep(millis) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => resolve('Slept enough!'), millis);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* let t = Date.now()
|
||||
* sleep(100).then(() => console.log(Date.now() - t)) // 100
|
||||
*/
|
Loading…
Reference in a new issue