How does the cumputer know to use what i defined in the animal prototype?

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");
}
};

Challenge: Use Inheritance So You Don’t Repeat Yourself

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

how does the cumputer know to use what i defined in the animal prototype?
i dont see anywhere that animal keyword is being used in Cat or Bear…

1 Like

for now, it doesn’t, you will set that up in the following challenges

2 Likes