19. Black and White Penguin Magic

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/objects-ii/3/4?curriculum_id=506324b3a7dffd00020bf661#

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
ReferenceError: Penguin is not defined

```

// the original Animal class and sayName method
function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
console.log("Hi my name is " + this.name);
};

function Penguin(name) {
this.name = name;
this.numLegs = 2
}
Penguin.prototype = new Animal();
var Penguin = new Penguin(“Zain”);
penguin.sayName( );

<do not remove the three backticks above>
2 Likes

Hi this line

var Penguin = new Penguin("Zain");

this part

var Penguin ..

you wrote Penguin instead of penguin should be with the downcase p

1 Like

I’m having the same problem, however I get the error message “TypeError: penguin.sayName is not a function”

HI can you post your code

// the original Animal class and sayName method
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 Penguin(name) {
this.name = name;
this.numLegs = 2;
}

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

var penguin = new Penguin(“Jerry”);
penguin.sayName();

HI this line

Penguin.prototype.sayName = new Animal()

you should remove the sayNAme so it should be like that

Penguin.prototype = new Animal()

ok thanks, sorry didn’t pay attention to your other response

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