JavaScript promises, mastering the asynchronous

Magus
8,476 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

The code snippet below is synchronous. It calls callback1 one time and callback2 three times. You must modify this code to make it asynchronous with the following rules:

  • callback1 must be called only one time, after 2 seconds.
  • callback2 must be called three times with an interval of 1 second.
Change the code to make it asynchronous
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content
1
2
function job(callback1, callback2) {
callback1();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX