17. Marching Penguins


#1

Hi guys, I have one question.
Shouldn't var Pengiun = new Animal("some_name", 10); should also create new Penguin with given name and age?
I am getting Penguin is not a function error.

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


// create a Penguin constructor here
var Penguin = new Animal("Bob", 21);

// create a sayName method for Penguins here


// our test code
var theCaptain = new Penguin("Captain Cook", 2);
theCaptain.sayName();

#2

The comments suggest that you should create a Penguin constructor, but you created an instance of Animal by using the Animal constructor. A Penguin constructor would allow you to create instances of Penguin


#3

Ah, ok I get it. Thank you for clarification @ionatan !