2621. Sleep
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : July 09, 2024
Last updated : July 09, 2024
Related Topics : N/A
Acceptance Rate : 87.42 %
/**
* @param {number} millis
* @return {Promise}
*/
async function sleep(millis) {
return new Promise(resolve => setTimeout(resolve, millis));
}
/**
* let t = Date.now()
* sleep(100).then(() => console.log(Date.now() - t)) // 100
*/
async function sleep(millis) {
return new Promise((resolve=millis, reject) => setTimeout(resolve, millis));
}