Tell us what’s happening:
i want to how my eat function is available to the bear & cat .i know it’s working but i wan t to how it works behind the sceen. how my cat and bear is accessing the eat function which i present in animal.
Your code so far
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");
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
.
Challenge: Use Inheritance So You Don’t Repeat Yourself
Link to the challenge: