Penguins, Properties, and the Prototype. Whats wrong?


#1

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

// create your Emperor class here and make it inherit from Penguin
Emperor.prototype = new Penguin();

// create an "emperor" object and print the number of legs it has
//var emperor = new Emperor ("Adam");
//console.log(emperor.numLegs);


#2

The class needs to be defined before it can be made to inherit from a parent class.

Follow the pattern used to define the Penguin class, but leave out numLegs since that will be inherited. Be sure to give the new class a name attribute.


#3

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