Code Studio · Level 12
Capstone Challenge
Build your own mini game using a class, at least one array, methods, score, and a win rule.
Build your final game.
Example code
class AdventureGame {
constructor(hero) {
this.hero = hero;
this.score = 0;
this.items = [];
}
collect(item, points) {
this.items.push(item);
this.score += points;
}
play() {
this.collect("star", 10);
this.collect("shield", 5);
if (this.items.includes("star") && this.score >= 15) {
say(this.hero + " wins the adventure!");
} else {
say(this.hero + " keeps exploring.");
}
}
}
let finalGame = new AdventureGame("Nova");
finalGame.play();
Program result
- Run your code to see output.
Type real JavaScript, then run it.
Capstone challenge complete.
You built a complete mini game with state, actions, and a final rule.
Finish Code Studio