Skip to content
WANCODE
BM

Fix the Counter

10 minBeginnerReact

The stall owner wants a simple counter for cups sold. The buttons are there, and the console even shows the count going up… but the number on screen is stuck at 0.

  • Start: 0. Click +1 three times → 3.
  • Then click −1 → 2.
  • Reset → 0. Clicking −1 at 0 keeps it at 0 (you can't sell minus one cup).

Constraints

  • Keep the ids count, increase, decrease and reset.
  • Use React state — the screen must update because the component re-renders.

Make the teh tarik counter work: +1 adds one, −1 subtracts one (but never below 0), and Reset goes back to 0 — with the number on screen updating every time.

Checks

  • +1 updates the number on screen
  • −1 subtracts one
  • Reset goes back to 0
  • The count never goes below 0
Preview

Console output from your code appears here.

Step 1 of 1