OOP Studio Ages 9-15
Object Challenge
Create your own class, make at least two objects, and call one method on each object.
Create your own blueprint.
Example code
class PowerUp {
constructor(name, points) {
this.name = name;
this.points = points;
}
activate() {
say(this.name + " gives " + this.points + " points");
}
}
let star = new PowerUp("Star", 10);
let shield = new PowerUp("Shield", 5);
star.activate();
shield.activate();
Program result
- Run your code to see output.
Type real JavaScript, then run it.
OOP challenge complete.
You created a class blueprint, made two objects, and used their method.
Next Lesson