19.Black (and White) Penguin Magic


// 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 pengiun = new Penguin ("Pingo");

I refreshed the page, and I don't see any mistake? any ideas?


You define pengiun but use penguin. Typo.


I just rewrote the same code and it worked, really weird..


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