Inheritance Section

Tell us what’s happening:
I do not see how a relationship is established from “Cat” and “Bear” such that
“Animal” becomes the supertype.
With the way it is written, it appears that Javascript somehow already knows “Cat” and “Bear” are
an animal so it knows to associate “Cat” and “Bear” with “Animal”.
I highly doubt that this is the case.

It is not clear to me how the relationship is established such that “Animal” is a supertype for
“Cat” and “Bear”. Nowhere in the supertype “Animal” is “Cat” or “Bear” even mentioned. Nowhere in the subtypes is “Animal” mentioned for “Cat” or “Bear”. I am missing how the relationship is being established.

Is it possible the relationship is established based on the order the objects are in the code?
Is it like SQL Server in how code is executed in that it executes the relationship from the bottom to the top of the code?

Your code so far

function Cat(name) { = name;

Cat.prototype = {
constructor: Cat  

function Bear(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/78.0.3904.108 Safari/537.36.

Challenge: Use Inheritance So You Don’t Repeat Yourself

Link to the challenge:

This challenge introduces the idea of putting methods that will be common across all animal types in a supertype (in this case Animal). At this point, there is no direct relation. In the next challenge, you use what you did here actual make the connection back to the Animal prototype.