Object Oriented Programming - Use Inheritance So You Don't Repeat Yourself

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/ Safari/537.36

Challenge: Object Oriented Programming - Use Inheritance So You Don’t Repeat Yourself

Link to the challenge:

Ok! Just a suggestion, but maybe in the lesson put an asterisk that says you will learn how to connect them in later challenges.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.