Skip to main content
Problem 9

Cooldown Button

MEDIUMBUILD
DOM+2

Given an integer cooldownSeconds, build a cooldown button using HTML, CSS, and JavaScript. Render a button with data-testid="cooldown-button" and a label with data-testid="cooldown-label". Initial state: button enabled, label text "Ready". On click: disable the button, count down each second with label text "Wait {n}s", then re-enable and reset label to "Ready". Clicks while disabled have no effect.

Examples
Example 1
Input
cooldownSeconds = 3, user clicks at t=0
Output
Label sequence: "Wait 3s" → "Wait 2s" → "Wait 1s" → "Ready". Button re-enables after 3 seconds.
Constraints
  • Label text must match the exact format "Wait {n}s" / "Ready"
  • Cooldown timing must not drift on repeated clicks
Follow-up

Persist the cooldown end time so the cooldown continues correctly after a page reload.

Hints
Console output will appear here...