19. Black (and White) Penguin Magic


#1

hey i get it accepted but i can get it to log anything.

// 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('bob');
penguin.sayName();

#2

Hello @mathewvirgen,

Your code should work, it has the correct syntax for everything. Try reloading your page... that sometimes fixes the problem.

Regards,
Barry Allen


#3

@bartholomewallen thanks, that worked. I just have to do that every time something isn't working. I thought i was blind :stuck_out_tongue:


#4

Haha, yeah Codecademy is a great tool, but it's definitely not a perfect one. Keep coding hard :laughing:!

Regards,
Barry Allen


#5

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