Code Studio · Level 8
Class Challenge
Create your own class, make an object from it, and call one method.
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();
Program result
- Run your code to see output.
Type real JavaScript, then run it.
Class challenge complete.
You created a JavaScript class, made an object, and called a method on it.
Next Lesson