Skip to main content

JavaScript Promise.all — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Promise.all 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

    Wait for two promises

    easy10 min

    Use Promise.all and report both values joined by a comma.

  2. 2

    Keep the input order

    easy10 min

    Show that results follow the input order, not the finishing order.

  3. 3

    Handle one failure

    easy10 min

    Catch the rejection that Promise.all passes on.

  4. 4

    Report every outcome

    easy10 min

    Use allSettled and report the two statuses joined by a comma.

  5. 5

    Take the first to finish

    medium10 min

    Use Promise.race and report the quicker value.

Find the bug(5)

  1. 1

    Fix the promises awaited one at a time

    easy8 min

    Independent work should run together with Promise.all.

  2. 2

    Fix the array not passed

    easy8 min

    Promise.all takes one array, not separate arguments.

  3. 3

    Fix all used where allSettled is needed

    easy8 min

    One rejection loses every result, but each outcome is wanted.

  4. 4

    Fix the results sorted by finishing time

    easy8 min

    Promise.all already returns them in input order.

  5. 5

    Fix race used where all is needed

    easy8 min

    Every value is wanted, not just the first to arrive.

Ready to write the code?

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

Open the workspace