19/30 Black Magic


#1
// 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();
penguin.sayName();

Why when it prints it says undefined?


#2

Sorry I can't help you. I'm just replying so it goes back to the top as nobody has answered you yet


#3

Thanks dude,
Got it done.


#4

I've done it right but it hasn't printed out anything to the console :frowning: