Create a gist now

Instantly share code, notes, and snippets.

class Lannister {
dieNext() {
const victim = [
'Tyrion',
'Cersei',
'Jamie'
];
console.log(`${this.name} is going to kill ${victim[Math.floor(Math.random() * victim.length)]}!`);
}
constructor(data) {
this.name = data.name;
this.father = data.father;
this.hairColor = data.hairColor;
}
}
class Stark extends Lannister {
constructor(data) {
super(data.name, data.status);
this.name = data.name;
this.status = data.status;
}
}
let Joffrey = new Stark({ name: 'Joffrey', father: 'Jamie', status: 'Dead' });
Joffrey.dieNext(); //Joffrey is going to kill Tyrion! 😰
console.log(Joffrey.status); // Dead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment