Use Inheritance So You Don't Repeat Yourself(Why animal is the supertype of others)

Use Inheritance So You Don't Repeat Yourself(Why animal is the supertype of others)
0

#1

Tell us what’s happening:
I can pass this challenge, but I still feel confused.
Why the property like eat in the animal can represent the property in the dog or bird. Which line of the code declare the animal is the supertype(parent) of others.

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 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-inheritance-so-you-dont-repeat-yourself


#2

I understand your confusion. Nothing is being inherited yet. Submit your challenge answer and go forward for more information in the next challenge.
hope this helps.