Black ( and White ) Penguin Magic


(ReferenceError: NewPenguin is not defined) I don't know exactly what's wrong, I was hoping for some help. Thank you in advance.

Penguin.prototype = new Animal();

var penguin = NewPenguin('bob')

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

// define a Penguin class
function Penguin(name){ = name;
    this.numLegs = 2;

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

var penguin = new Penguin('bob');


On the second line:

var penguin = NewPenguin('bob')

This should be:

var penguin = new Penguin('bob');

It thinks NewPenguin is a variable, But you create a new object using the new keyword.


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