Penguins, Properties, and the Prototype


#1

Mine says to 'make sure to log the number of legs emperor has!'. I checked it against all the topics with similar questions, but found nothing wrong.

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


#2

New update: through random typing out of pure exasperation, I discovered that if one simply types console.log(2); then the exercise lets you past. Just sayin'.


#3

Aaaand yet another update. I solved the problem. My new 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();
console.log(emperor.numLegs);


#4

Thanks for the update. I was quite confused too...


#5

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