Skip to content

Files

Latest commit

 

History

History

152-wait

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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