All challenges

TypeScript · medium

Two doors

#30

Situation

The home dashboard currently loads user then prefs in series. But fetchUser resolves only after the preferences request has started, so waiting for one before starting the other deadlocks the page.

Objective

Start both requests without deadlocking, then return the matching user and theme. loadHome(1) resolves to { user: "Ada", theme: "dark" }, and every other id returns its own name.

The repo at start

workspace/
└── src/
    └── dashboard.ts   (awaits A before starting B; A refuses)

Checks you will turn green

  • exports loadHome
  • loadHome joins user and theme
  • another id loads its own user

Concepts

async-awaitconcurrency

Play it in your terminal

With sharpen installed, this command opens exactly this challenge in your local arena:

sharpen 30

First time? The full install is right below.

How to play

  1. 1 Install Claude Code if you do not have it yet: claude.com/claude-code
  2. 2 Install sharpen from npm:
    npm install -g @juanwmedia/sharpen
  3. 3 Then launch it; the arena opens in your browser:
    sharpen 30
  4. or Or try it without installing anything:
    npx @juanwmedia/sharpen 30
  5. 4 And to update when a new version ships:
    sharpen update