en.javascript.info/8-async/02-promise-basics/02-delay-promise/task.md
Ilya Kantor cce95cb631 up
2017-04-23 02:33:24 +03:00

14 lines
366 B
Markdown

# Delay with a promise
The built-in function `setTimeout` uses callbacks. Create a promise-based alternative.
The function `delay(ms)` should return a promise. That promise should resolve after `ms` milliseconds, so that we can add `.then` to it, like this:
```js
function delay(ms) {
// your code
}
delay(3000).then(() => alert('runs after 3 seconds'));
```