19.Black (and White) Penguin Magic


#1


https://www.codecademy.com/courses/objects-ii/3/4?curriculum_id=506324b3a7dffd00020bf661


I cant see where my mistake is. The error message is 'Oops, try again. Your code threw the following error: TypeError: Right-hand side of 'instanceof' is not callable'


// 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("Muhsin");
penguin.sayName();


#2

this line:

var Penguin = new Penguin("Muhsin");

you can't give the variable the same name as the object, that is a conflict. you could call it penguin, since this is a different name (variable names are case sensitive)


#3

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