Black (and White) Penguin Magic


#1


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


Error: Oops, try again. Make sure to create a new Penguin instance called penguin!


Replace this line with your code. 
// the original Animal class and sayName method
function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
console.log("Lol my name is " + this.name);
};



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




//set its prototype to be a new instance of Animal
Penguin.prototype = new Animal();

var penguin = new Penguin("Jeeefffffffffff");



penguin.sayName();

I'm stuck Help!


#2

Check this part of your code...

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

Problem, Can you find it?


#4

thanks

function Penguin(name) {
   //Penguin.prototype = new Animal(); 
   this.name = name;
   this.numLegs = 2;
}

#5

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