I passed with a reference error


#1


All I want to know is "Why do I get a reference error?"


// create your Animal class here
function Animal(name, numLegs) {
    this.name = name;
    this.numLegs = numLegs;
}
// create the sayName method for Animal
Animal.prototype.sayName = function() {
    console.log("Captain Cook");
    console.log(numLegs)

};
// provided code to test above constructor and method
var penguin = new Animal("Captain Cook", 2);
penguin.sayName();


Here's what is logging to my console.

Captain Cook
ReferenceError: numLegs is not defined


#2

    console.log(numLegs);

when I type this into the code I pass but I get a reference error


#3

Where's the problem with my code?


#4

@minecraftmaster02
please delete this topic as it is a duplicate !!


#5

I can't delete as the fact that i'm not a moderator


#6

you can delete as you are the owner....


#7

How wold I delete it then? here's what I see with my extra stuff tab


#8

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