Penguins, Properties, and the Prototype. Whats wrong?


function Penguin(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");


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.


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