20. Penguins, Properties, and the Prototype


#1

https://www.codecademy.com/courses/objects-ii/3/5?curriculum_id=506324b3a7dffd00020bf661#

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


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


#2

The code didn't work yesterday.

Today I entered the page and did no change to the code, but it worked this time.


#3

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