Command Palette

Search for a command to run...

Hectal
Phase 10: Asynchronous JavaScript
JavaScript · Exercise 2 of 5 PreviousNext
Intermediate

Put the event loop in order

The console should print the letters A, B, C, D, E, F, each on its own line, in that order.

Rules: don't move any line and don't change the letters. You may only wrap a console.log(...) line in setTimeout(() => ..., 0), queueMicrotask(() => ...) or Promise.resolve().then(() => ...).

Predict on paper first: which queue does each letter need to go in?

What Check tests

  1. The console prints A, B, C, D, E, F in order
  2. No line was moved
  3. At least one line uses a microtask
  4. No errors

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.