Sleep Function
Sleep Function
Create a function that pauses execution for a specified duration.
Requirements:
- Implement a
sleepfunction that returns a Promise - The Promise should resolve after the specified milliseconds
- Should work with async/await
Example:
async function demo() {
console.log('Start');
await sleep(1000); // Wait 1 second
console.log('End');
}
Examples:
Input 1:
{"ms":100}Output 1:
"resolved"Input 2:
{"ms":500}Output 2:
"resolved"Loading editor...
Run your code to see results
Click the Run button above