Penguin Magic


#1

Penguin magic distinctly lacking for me, getting the error message "ReferenceError: penquin is not defined" but surely it's defined under var penguin (or am I missing something?)


// 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 = new Animal();

var penguin = new Penguin("Pingu");
penquin.sayName();


#2

Witness the spelling error. It's the only thing wrong that I can see.


#3

Aaaarggghh! Thanks MTF


#4

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