FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Easy

Sleep

10mins

Implement a function sleep(ms) that pauses execution for the specified number of milliseconds before resolving a Promise.

Example

console.log("Start"); await sleep(1000); console.log("End"); // Logs "End" after ~1 second

Code Editor

JavaScript Function

00:00
Loading...

Test Cases

No test results yet

Click "Run" to execute tests