Back to Capstone Mini Game
Code Studio · Level 12

Capstone Builder

Students customize the final game title, goal items, score values, and ending message.

20-25 min Ages 9-12 Builder JavaScript
Code Editor

Customize the final project.

Example code
class MiniGame {
  constructor(title, requiredItem) {
    this.title = title;
    this.requiredItem = requiredItem;
    this.score = 0;
    this.items = [];
  }

  collect(item, points) {
    this.items.push(item);
    this.score += points;
    say("+" + points + " for " + item);
  }

  hasWon() {
    return this.items.includes(this.requiredItem) && this.score >= 15;
  }

  report() {
    say("Game: " + this.title);
    say("Items: " + this.items.join(", "));
    say("Score: " + this.score);
    say(this.hasWon() ? "You win!" : "Try one more quest.");
  }
}

let game = new MiniGame("Moon Garden", "moon seed");
game.collect("map", 5);
game.collect("moon seed", 10);
game.report();
Output

Program result

Robot ready to speak your strings

Type real JavaScript, then run it.