JavaScript promises, mastering the asynchronous
Magus
434K views
Let's do some practice with a simple exercice. You must modify the code below based on the following rules:
- The function
job
must return a promise object (you are in a NodeJS environment, you can usenew Promise
) - The promise must resolve itself 2 seconds after the call to
job
and must providehello world
in the data
Change the code to return a promise
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
1
2
3
4
5
function job() {
return 'hello world';
}
module.exports = job;