I don’t understand how the eat function is linked to Bear or Cat? Animal isn’t named as a supertype of either so how are they linked and thus how is the eat function applied to the other to subtypes like its meant to be?
function Cat(name) {
this.name = name;
}
Cat.prototype = {
constructor: Cat,
};
function Bear(name) {
this.name = name;
}
Bear.prototype = {
constructor: Bear,
};
function Animal() { }
Animal.prototype = {
constructor: Animal,
eat: function() {
console.log("nom nom nom");
}
}
.eat()
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.41
Challenge: Object Oriented Programming - Use Inheritance So You Don’t Repeat Yourself
Link to the challenge: