Marching Penguins - Error Message


Marching Penguins exersice here


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


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


returning statement should be exactly added a extra ,


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:


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