Marching Penguins


#1

Hi Guys,
I really didnt get this clearly. I created Penguin Constructer and then sayhello function. Please help me as I am really struggling on this.


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(){
    name='helllo';
    numLegs=2;
};

// create a sayName method for Penguins here
Penguin.sayName();

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


#2

The idea here is to follow the example shown in the Animal constructor.

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

Again, the idea is to follow the example above for Animal.prototype...

______.prototype._______ = function() {

}

#3

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