Whack A Mole

MediumWhack A MoleReactGameWhack-a-mole-for-frontend30 mins

by Pratik Rai

Read the full write-up

Build whack-a-mole. Press Start and a mole appears in a random hole, moving every 800ms. Hit it to score. The round lasts 20 seconds.

Requirements

  1. Start begins a round: score back to zero, timer back to 20, mole moving.

  2. The mole jumps to a random hole every 800ms while the round is running.

  3. Clicking the hole with the mole scores a point; clicking an empty hole does nothing.

  4. The same mole cannot be scored twice — a second click before it moves is worth nothing.

  5. The timer counts down once a second and the round ends at zero, with the mole gone and Start available again.

  6. Every timer is cleared when the round ends or the component unmounts.

Notes

  • Difficulty ramps, combos and a high score are natural follow-ups and are out of scope.

  • The .hole-up class already styles a hole with a mole in it.

Hints

Loading editor…