Custom Delay Function

Custom Delay Function

Easy NodeJS Async & Event Loop 34 views
Explanation Complexity

Problem Statement

Create a delay(ms) promise and use it with await.

Input Format

No input.

Output Format

Print DONE.

Constraints

Use setTimeout wrapped in Promise.

Input / Output Format

Input Format
No input.
Output Format
Print DONE.
Constraints
Use setTimeout wrapped in Promise.

Examples

Input:
Output:
DONE

Example Solution (Public)

NodeJS
function delay(ms) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

(async () => {
  await delay(30);
  console.log('DONE');
})();

Official Solution Code

function delay(ms) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

(async () => {
  await delay(30);
  console.log('DONE');
})();
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.