Command Palette

Search for a command to run...

Hectal
Phase 10: Asynchronous JavaScript
JavaScript · Exercise 5 of 5 Previous
Intermediate

A dashboard that loads in parallel

Three fake servers are given: getUser() (200 ms), getOrders() (300 ms) and getWeather() (fails after 250 ms). Don't change them.

Write loadDashboard() so that clicking Load: disables the button and sets #status to Loading…; loads all three at the same time; shows Hello, Asha in #user, 3 orders in #orders, and the weather in #weather, or Unavailable if that request failed; then sets #status to Done and enables the button again.

One failure must not stop the other parts from showing, and nothing should end up as an uncaught error.

What Check tests

  1. Clicking Load disables the button and shows Loading…
  2. All three load in parallel (done within 450 ms)
  3. Shows Hello, Asha and 3 orders
  4. The failed weather request shows Unavailable
  5. The button works again after loading
  6. No uncaught 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.