Penguins, Properties, and the Prototype


#1


My error: Oops, try again. Make sure to log the number of legs emperor has!


My error: 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;
};

// create an "emperor" object and print the number of legs it has
Emperor.prototype = new Penguin();
var emperor = new Emperor("Duke");

console.log (emperor,numLegs);

Need your help, thanks.
I don't know how to log the number of legs emperor  has ????


#2

I just solved my question, after I change console.log (emperor,numLegs); into
console.log (emperor.numLegs);
thanks, guys.


#3

console.log(Emperor.numLegs) should work.

You're taking the numLegs value from the Emperor object.


#4

That tiny comma was the headache eh?


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.