Marching Penguins - Error Message


#1

Marching Penguins exersice here

Instructions

Create a brand new Penguin class constructor starting in line 11. A penguin is an animal so it should also have the name and numLegs properties as well as a sayName method that prints the same thing as Animal's sayName method.

We’re not done with animals yet, so we have still included the Animal constructor and its sayName method. The last two lines test your Penguin code.



My Code

//Animal constructor here
function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
//animal method here
Animal.prototype.sayName = function() {
console.log("Hi my name is " + this.name);
};
//Penguin constructor here
function Penguin(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
//sayName method for Penguins here
Penguin.prototype.sayName = function() {
console.log("Hi, my name is " + this.name);
};
//test code
var theCaptain = new Penguin(“Captain Cook”, 2);
theCaptain.sayName();

Output

Hi, my name is Captain Cook

Error Message

Oops, try again. It looks like your Penguin.prototype.sayName method doesn’t return ‘Hi my name is [name]’ where [name] is the penguin’s name


#2

returning statement should be exactly same.you added a extra ,


#3

Exactly as he says. It’s just the way they check if you have completed an exercise or not: by checking for keywords or certain strings, etc.
Sometimes all your code must be precisely as they expect: you cannot add anything, be it a string to enhance the output for you console.log, for example :slight_smile:


#4

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