Count Down to Zero

Write the code, see it run, pass the checks.

The problem

  • easy
  • Code

Build a countdown that starts by itself when it mounts. Its props: from, the starting number (default 10); interval, the milliseconds between steps (default 1000); and onDone, a function to call when it finishes. It shows a paragraph reading "Seconds left: 10" (with the from number), going down by 1 every interval. When it reaches 0, show "Time is up!" instead, call onDone() exactly once and stop. If it unmounts before the end, it must stop and never call onDone. The checks use intervals of 30 to 60 milliseconds.

Your code must pass

  • Shows "Seconds left: 3" at first, then counts down
  • Ends with "Time is up!" and calls onDone once
  • Stops when unmounted early