Penguins, Properties, and the Prototype


#1


Penguins, Properties, and the Prototype


The code is not working the message i receive is:

Oops, try again. Make sure to properly define the Emperor constructor!


Replace this line with your code. 
function Penguin(name) {
    this.name = name;
    this.numLegs = 2;
}

// create your Emperor class here and make it inherit from Penguin
Penguin.prototype.Emperor = function(name) {
    this.name = name;
}

// create an "emperor" object and print the number of legs it has
var emperor = new Emperor("test");

emperor.numLegs();


#2

When creating a class that inherits from a parent, we write it,

SubClass.prototype = new ParentClass();

#3

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