Penguins, Properties, and the Prototype


#1


Penguins, Properties, and the Prototype


It keeps telling me to log the number of legs

it doesn't count as a pass, but the console does print 2 when I use emporer.numLegs without console.log()

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("bob");

console.log(emperor.numLegs)

#2

you didn't print that.Actually system prints for you.

Add console.log at the end.print anything you want.now it'll not print 2.


#3

Wow, that seems odd.. But it works, so thanks!


#4

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