Skip to content

Instantly share code, notes, and snippets.

@TheCodingLady
Last active March 31, 2018 11:33
Show Gist options
  • Save TheCodingLady/8bc9a14bcc6d4cfb7bd148564ff5eda4 to your computer and use it in GitHub Desktop.
Save TheCodingLady/8bc9a14bcc6d4cfb7bd148564ff5eda4 to your computer and use it in GitHub Desktop.
js class, constructor, etc
class Monster {
constructor(options) {
this.name = name;
this.health = 100;
}
heal() {
return this.health += 10;
}
}
class MiniMonster extends Monster {
constructor(options) {
super(name);
this.health = 50;
}
heal() {
return this.health += 5;
}
}
let Cheeto_Man = new Monster(name = "Donald");
let Robo_Dog = new MiniMonster(name = "Spot");
console.log(Cheeto_Man.name + " is " + Cheeto_Man.health + "% " + "monster.");
console.log(Robo_Dog.name + " is " + Robo_Dog.health + "% " + "monster.");
module.exports = {
Monster,
MiniMonster
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment