Skip to content

Latest commit

 

History

History

2621. Sleep

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

2621. Sleep

Write an asynchronous function that accepts a positive integer millis and sleeps for that many milliseconds. It can resolve any value.

Examples

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