Tell us what’s happening:
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/85.0.4183.102 Safari/537.36
.
Challenge: Use Inheritance So You Don’t Repeat Yourself
Link to the challenge:
Can you explain what you mean in greater detail please?
Sorry, this was two stages.
removing the eat from Bear and Cat has removed the functionality,
Moving to Animal did not solve the DRY.
Thanks for super quick reply.
I still don’t fully understand what you mean, but connecting the animal base class to the cat and bear derived classes is the next lesson.
Da_vey
5
You must make “Bear and “Cat”” inherit from Animal
after moving eat property to animal
so they can call eat()
correct, but that was the next step.