๐ŸŽฎ
Code Studio ยท Ages 9โ€“12

Button Blaster

Click to score points, then spend them on silly upgrades that make every blast worth more. Play it first โ€” then build the blaster with real JavaScript using a variable, an action, and if / then to unlock upgrades.

Play it

Blast the button!

๐ŸŽฏ Goal: blast to earn points, then buy all 5 upgrades to become the Ultimate Blaster!

Difficulty:

This is the kind of extra code that powers the level you picked โ€” try reading it!

0
points
+1 per blast

๐Ÿ›’ Upgrade shop 0 / 5 owned

๐Ÿ† You did it! You own every upgrade โ€” you're the Ultimate Blaster!

How the blaster works

A clicker game is built from three small coding ideas working together.

๐Ÿ“ฆVariableremembers your score
๐Ÿ‘†Actiona click adds points
๐Ÿ”“If / thenunlocks upgrades
let score = 0;
let perClick = 1;

// this runs every time you click BLAST
function blast() {
  score = score + perClick;

  // when you reach 20 points, unlock an upgrade
  if (score >= 20) {
    unlock("Auto-Blaster");
  }
}
Now you code it

Code Lab: build the blaster

You're building the code that runs each time the button is blasted โ€” the inside of the blast() function.

๐Ÿ“‹ How this Code Lab works

  1. Read the ๐ŸŽฏ Mission goal โ€” it tells you what your code should do.
  2. In Code blocks on the left, click a block to add it to your program on the right. The blocks run top to bottom.
  3. Need to change the order? Drag a block up or down (or use the โ†‘ โ†“ buttons). Tap ร— to remove one.
  4. Press โ–ถ Run code, then blast the live button that appears to test what you built.
  5. A green โœ… means you solved it โ€” a Next mission โ†’ button shows up. A blue ๐Ÿ’ก is a hint to try again.

๐Ÿ’ก Tip: score remembers your points, and perClick is how much one blast is worth.

๐Ÿงฑ Code blocks

Click to add to your blast action.

๐Ÿ“ When the button is blastedโ€ฆ

function blast() {

}

0 points
+1 per blast