Supertype/DRY Challenge

Tell us what’s happening:
Describe your issue in detail here.
I was able to pass this challenge so I don’t have any code specific questions but I am not sure I understand how the supertype works. In this example, how does the eat function remain a property of the objects Bear and Cat? In other words, how do the types know that Animal is a supertype?
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/96.0.4664.110 Safari/537.36

Challenge: Use Inheritance So You Don’t Repeat Yourself

Link to the challenge:

Or is this what is explained in the next challenge and we need to have Object.create(Animal.prototype); inside the function?

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