Skip to content
ExploreMapGamesStoriesComicsVideosStudioPrintablesCode LabJourneys
By age โ–พ
  • ๐Ÿงธ Tiny Explorers2โ€“5
  • ๐Ÿฆ‰ Curious Learners6โ€“8
  • ๐Ÿ”ญ Young Investigators9โ€“12
  • ๐Ÿš€ Trailblazers13โ€“17
๐Ÿ‘คParent sign in
Kids Amazing World

A creative learning playground. No ads, no tracking, no chat. Every item is reviewed before it appears.

Explore

  • Explore
  • Learning journeys
  • Surprise me
  • Parent planner

For grown-ups

  • Child safety
  • Privacy
  • Terms (draft)
  • Free & Premium
  • Parent sign in

About this content

Some items in this build are placeholders written for development. Third-party resources are only listed with permission, a license, or an official embed.

โ† All game tutorials

๐Ÿ”จ Whack-a-Mole

Tap the mole before it hides.

How to playYour functionsSettings you can changeStep by stepIdeas to tryLessons

๐ŸŽฎ How to play

Reach the goal score before you run out of lives. Tap moles to score. A mole that escapes costs a life.

  • Tap or click a hole (or press Enter on it): Whack the mole if it is in that hole.

โš™๏ธ Your functions

You write these functions. The game calls them when something happens.

  • onWhack()

    Runs every time you tap the mole.

    function onWhack() {
      score = score + 1;
    }
  • onMiss()

    Runs when a mole hides before you tapped it.

    function onMiss() {
      lives = lives - 1;
    }

๐ŸŽš๏ธ Settings you can change

Variables at the top of your code are the game's settings. Change a value, press Play, and see what happens.

mole = "๐Ÿน"
The emoji that pops up.
goal = 8
Reach this score to win.
lives = 3
Moles you may let escape.
speed = 2
From 1 (slow) to 5 (fast).
score = 0
Your points. The game starts it at 0 and you change it in your functions. set by the game

๐Ÿชœ Step by step

Each step shows code you can add to the end of your game's code. A function or variable written later replaces the earlier one, so you never have to delete anything.

  1. 1Play the starter

    Tap the moles as they appear. onWhack runs on every hit, onMiss on every escape.

    function onWhack() {
      score = score + 1;
    }
  2. 2Worth more points

    Change the number to make every whack worth 3.

    function onWhack() {
      score = score + 3;
    }
  3. 3Fever mode

    A counter can switch a bonus on. After 5 whacks, every whack is worth double. Counting with a variable and testing it with if is how games track progress.

    let whacks = 0;
    
    function onWhack() {
      whacks = whacks + 1;
      if (whacks > 5) {
        score = score + 2;
      } else {
        score = score + 1;
      }
    }
Show the full starter code
// ๐Ÿ”จ Whack-a-Mole!
let mole = "๐Ÿน";   // who pops up
let goal = 8;          // reach this score to win
let lives = 3;
let speed = 2;         // 1 (slow) to 5 (fast)

function onWhack() {
  score = score + 1;
}

function onMiss() {
  lives = lives - 1;
}

๐Ÿ’ก Ideas to try

  • Whack-a-monster: make the mole a ๐Ÿ‘ป and the goal 20.
  • Give a bonus for whacking 3 moles in a row.
  • Speed the game up as your streak grows.

Tips

  • A higher speed number means moles hide faster. Try 4 for a challenge.
  • Save your game in the Studio when you like it, then share the tutorial link with a friend.

๐ŸŽ“ Lessons for this game

  • ๐Ÿ”’Whack-a-MolePremium
  • ๐Ÿ”’Combo streakPremium

๐Ÿ› ๏ธ Make your own Whack-a-Mole game

Game Studio and the full lessons are part of Premium.

See Premium
โ† ๐Ÿงบ Catch the Starsโ“ Quiz Show โ†’