Back

Async Patterns / Delay with Promise

00:00
1/20

Delay with Promise

Easy

Write a function delay(ms) that returns a Promise that resolves after ms milliseconds.

  • 1

    Create a new Promise.

  • 2

    Inside, use setTimeout.

  • 3

    Call resolve when the timeout completes.

JAVASCRIPT PLAYGROUND
JAVASCRIPT PLAYGROUND
⏳ Loading editor…