Dry Penguins. What is wrong?


What is wrong with the code below? Why is the numLegs coming back as undefined?


Oops, try again. The Penguin constructor should always set this.numLegs to 2. The constructor should only take a single parameter!

function Animal(name, numLegs) {
    this.name = name;
    this.numLegs = numLegs;
Animal.prototype.sayName = function() {
    console.log("Hi my name is " + this.name);

// define a Penguin class
function Penquin( name ) {
    this.name = name;
    this.numLegs = 2;

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


You forgot to add numLegs to the functions parenthesis. The parenthesis needs to look like what you already did above.


I found the issue... Penguin is not Penquin.


Oh fair play didn't even notice that.


If it wasn't for you separating my code into small chunks like that, I may have never found it. Thank you.


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