Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 1.64 KB

File metadata and controls

21 lines (16 loc) · 1.64 KB

wait medium #javascript

by Pawan Kumar @jsartisan

Take the Challenge

Implement a wait function that pauses the execution of code for a specified number of milliseconds. The wait function should return a Promise that resolves after the given time has elapsed.

Example usage

async function demo() {
  console.log('Start');
  await wait(2000); // Pauses for 2 seconds
  console.log('End');
}

demo();
// Output:
// Start
// (waits for 2 seconds)
// End

Back Share your Solutions Check out Solutions