Code Studio · Level 8
Class Builder
Students add a method to a class and create more than one object from the same blueprint.
Build two characters.
Example code
class Character {
constructor(name, tool, level) {
this.name = name;
this.tool = tool;
this.level = level;
}
showCard() {
say(this.name + " carries a " + this.tool);
say("Level " + this.level);
}
}
let nova = new Character("Nova", "debug wand", 3);
let milo = new Character("Milo", "loop boots", 4);
nova.showCard();
milo.showCard();
Program result
- Run your code to see output.
Type real JavaScript, then run it.
Class builder complete.
You used one class blueprint to create two different character objects.
Try Class Challenge