Skip to main content

JavaScript Asynchronous — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Asynchronous lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.

Exercises(5)

  1. 1

    Report the running order

    easy10 min

    Use a timer to build the order first, second, third.

  2. 2

    Show the result is not ready

    easy10 min

    Read a value before the timer sets it and report what you get.

  3. 3

    Use the value where it arrives

    easy10 min

    Report the value from inside the callback, once it exists.

  4. 4

    Show a timer waits its turn

    easy10 min

    Even a delay of zero runs after the current code, so report both in order.

  5. 5

    Count synchronously first

    medium10 min

    Finish a loop, then report from a timer that the loop went first.

Find the bug(5)

  1. 1

    Fix the value read too early

    easy8 min

    The value is read before the timer has set it.

  2. 2

    Fix the order assumed to be top to bottom

    easy8 min

    The timer callback runs after the code below it.

  3. 3

    Fix the result expected as a return

    easy8 min

    A function that schedules work cannot return its result.

  4. 4

    Fix the missing report

    easy8 min

    The timer updates a variable but never shows it.

  5. 5

    Fix the order built in the wrong place

    easy8 min

    The join happens before the timer has added its entry.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace