Back to Game Builder
Code Studio · Level 9

Game Engine Challenge

Create a tiny game object that changes score, stores items, and prints a final status.

10-15 min Ages 9-12 Challenge JavaScript
Code Editor

Build your own game state.

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

  earn(item, points) {
    this.items.push(item);
    this.score += points;
  }

  finish() {
    say(this.title + " complete!");
    say("Score: " + this.score);
    say("Items: " + this.items.join(" + "));
  }
}

let game = new Game("Star Rescue");
game.earn("star", 10);
game.earn("key", 5);
game.finish();
Output

Program result

PLAYER 1 SCORE 0
Your player character
Robot ready to speak your strings

Type real JavaScript, then run it.