Objects 2 Emperor penguin (Needs Debug)


#1


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


// create your Emperor class here and make it inherit from Penguin


// create an "emperor" object and print the number of legs it has
function Emperor (name) {
this.name = name;
this.numLegs = 2;
}
Emperor.prototype = new Penguin("George");
console.log(Emperor.numLegs);


#2

here:

Emperor.prototype = new Penguin("George");

here you extend Penguin, so Emperor inherits from penguin

then you should create a emperor (instance) with a name


#3

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