Penguins, Properties, and the Prototype . what is wrong with my code?


#1

Penguins, Properties, and the Prototype

Penguins, Properties, and the Prototype

ReferenceError: numLegs is not defined..
Oops, try again. Make sure to log the number of legs emperor has!



Replace this line with your code.
function Penguin(name) {
this.name = name;
this.numLegs = 2;
}

// create your Emperor class here and make it inherit from Penguin
function Emperor(name) {
this.name = name;};
Emperor.prototype = new Penguin();
// create an "emperor" object and print the number of legs it has
var emperor = new Emperor("lol");

console.log (emperor,numLegs);


#2

here:

var emperor = new Emperor("lol");

you create an instance called emperor. If you want to access a property of an instance this would require the following syntax:

instance.property

see the difference?


#3

i did not understand


#4

I found the mistake thanks


#5