Penguins, Properties, and the Prototype


#1


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

var emperor = new Emperor();



// create an "emperor" object and print the number of legs it has

console.log(emperor.numLegs);

I dont really understand why it doesnt log in emperor numLegs???


#2

A link to the lesson could help, but I found something:

function Penguin(name) {
    this.name = name;
    this.numLegs = 2;
}

Should there be a numLegs parameter?


#3

#4

The only difference between our code was that I named emperor


#5

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