Skip to content
Frontend live coding · 25 minutes

Stopwatch with laps

Build a stopwatch in React in 25 minutes. It shows the elapsed time as minutes, seconds and hundredths of a second. It has Start, Pause, Reset and Lap buttons and a list of lap times. The time must stay correct when the tab is in the background or the computer is busy, so you cannot count timer ticks. Explain your decisions while you code, as in a live round.

Requirements

  • Start begins counting; Pause stops and keeps the time; Start then continues from that time
  • Reset stops the stopwatch, sets the time to zero and clears the laps
  • Lap adds the current time to a list while the stopwatch runs
  • The elapsed time is computed from timestamps (performance.now or Date.now), not by adding a fixed amount on each tick
  • The display has the form mm:ss.hh with leading zeros
  • The timer is cleared on pause, on reset and on unmount
  • A button is disabled when it has no meaning, for example Lap while the stopwatch is stopped

What reviewers look for

What reviewers look for, the checklist and the stretch goals opens with a year in the app. What a year includes