Back to Class Builder
Code Studio · Level 8

Class Challenge

Create your own class, make an object from it, and call one method.

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

Write your own class.

Example code
class GameLevel {
  constructor(title, goal) {
    this.title = title;
    this.goal = goal;
  }

  start() {
    say("Level: " + this.title);
    say("Goal: " + this.goal);
  }
}

let levelOne = new GameLevel("Star Rescue", "pick up the star");
levelOne.start();
Output

Program result

Robot ready to speak your strings

Type real JavaScript, then run it.