Loading workspace…

Stopwatch

Languages

Build a stopwatch widget which can measure how much time has passed. It shows the current timer and has two buttons underneath: "Start/Stop" and "Reset".

Requirements

  • Start/Stop Button: Starts/stops the timer depending on whether the timer is running.
  • Reset: Resets the timer to 0 and stops the timer.
  • Display the elapsed time as a button, formatted into hours, minutes, seconds, and two-digit hundredths of a second. Leading zero-valued hour and minute segments may be omitted.
    • Complete units should carry at their exact boundaries rather than overflow into the smaller unit.
    • Clicking on the timer should start/stop the timer. The Start/Stop button's label should update accordingly as well.

You are free to exercise your creativity to style the appearance of the stopwatch. You can try out Google's stopwatch widget for inspiration and an example.

Changelog

  1. Elapsed time when stopping

    The official solutions record the elapsed time since the last timer tick when Stop is pressed. The displayed time includes time between timer callbacks.

  2. Hundredths and exact unit boundaries

    The elapsed time is displayed to two-digit hundredths of a second. The published checks cover exact second, minute, and hour boundaries to verify that each completed unit rolls over correctly.

  3. Elapsed time accounting in Angular

    The Angular solution preserves the total elapsed duration when formatting it for display. The format calculation previously modified the running total.