I’m starting to understand the constructors and prototypes, but I’m a little confused in the problem. How does Cat and Bear fall under the animal prototype. I don’t see anything linking them together. For it to work, the Animal constructor is created and it has all the properties of animal.prototype. Then Cat and Bear are created from the animal constructor, and they are constructors themselves each with their own prototype. Since both Cat and Bear prototypes both have the eat property we can move eat to animal.prototype and delete it from Cat and Bear proptotypes. The part thats missing is I don’t see Cat and Bear created under the animal prototype so I’m confused as to why they are connected. Sorry if this is long. Any help would be appreciated! (Also please point out flaws in my understanding)
**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/103.0.0.0 Safari/537.36
Challenge: Object Oriented Programming - Use Inheritance So You Don’t Repeat Yourself
Link to the challenge: