Extra
class Animal {
talk() {
console.log("?");
}
}
class Bird extends Animal {
talk() {
return `tweet tweet`;
}
fly() {
console.log("flap flap");
}
}
class Parrot extends Bird {
state = {
happinness: 0
};
talk(item) {
console.log(`${super.talk()} with a ${item}`);
}
sing(loud) {
return (this.state.happinness += loud);
}
}
var a = new Animal();
var b = new Bird();
var p = new Parrot();
a.talk(); //?
b.talk(); //tweet tweet
b.fly(); //flap flap
p.talk("cracker"); //tweet tweet with a cracker
p.fly(); //flap flap
p.sing(50); //50Last updated
Was this helpful?