Penguin, Properties, and the Prototype - Correct output, incorrect result?


#1


20. Penguins, Properties, and the Prototypes

The error I get is "Oops, try again. Make sure to log the number of legs emperor has!"
But in the console, it actually does log "2".


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("boo");
console.log = emperor.numLegs;


#2

HI this line

console.log = emperor.numLegs;

the console.log() has that structure

console.log(/*Here put what you want to print*/);

after you change it refresh the page


#3

Oh my gosh. Refreshing the page is what did it. I tried both formats! Thanks so much. :]


#4

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