Write a Sleep Function

Write the code, see it run, pass the checks.

The problem

  • easy
  • Code

Write sleep(ms): return a promise that resolves with undefined once ms milliseconds have passed, so async code can write await sleep(200) to pause. It never rejects. The checks use waits of 10 to 100 milliseconds.

Your code must pass

  • Returns a promise
  • Doesn't resolve before the wait is over
  • Resolves with undefined once the wait is over
  • Shorter waits finish first