2621. Sleep
Easy
316
17

Given a positive integer millis, write an asyncronous function that sleeps for millis milliseconds. It can resolve any value.

 

Example 1:

Input: millis = 100
Output: 100
Explanation: It should return a promise that resolves after 100ms.
let t = Date.now();
sleep(100).then(() => {
  console.log(Date.now() - t); // 100
});

Example 2:

Input: millis = 200
Output: 200
Explanation: It should return a promise that resolves after 200ms.

 

Constraints:

  • 1 <= millis <= 1000
Accepted
27.3K
Submissions
31.3K
Acceptance Rate
87.3%

Seen this question in a real interview before?
1/4
Yes
No

Discussion (0)
Copyright ©️ 2023 LeetCode All rights reserved