Custom Delay Function
NodeJS
Easy
4 views
Problem Description
Create a delay(ms) promise and use it with await.
Output Format
Print DONE.
Constraints
Use setTimeout wrapped in Promise.
Official Solution
function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
(async () => {
await delay(30);
console.log('DONE');
})();
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!