Dice Roller

MediumDice RollerReact20 mins

by Pratik Rai

Read the full write-up

Build a dice roller. The player picks how many dice to roll, presses Roll, and sees the faces, the total, and a short history of recent totals.

The Die component that draws the pips is given to you.

Requirements

  1. Rolling gives every die a fresh random value from 1 to 6.

  2. The number of dice follows the dropdown — picking 4 and rolling shows four dice.

  3. The total under the dice reflects the faces currently shown.

  4. Keep a history of the last five totals, most recent first.

  5. The total is announced to assistive tech when it changes (aria-live).

Notes

  • The pip layout is already solved by Die and PIP_CELLS. This problem is about deriving state.

  • Changing the dropdown does not need to re-roll immediately — the next roll picking up the new count is enough.

Hints

Loading editor…