15/30 Prototype Practice


#1


Maybe I'm tired, but I can't figure out what I'm missing.


Oops, try again. It looks like you have an error in your code. Here's the message: ReferenceError: cat is not defined
ReferenceError: cat is not defined

unction Cat(name, breed) {
    this.name = name;
    this.breed = breed;
}
var cheshire = new Cat("Cheshire Cat", "British Shorthair");
var gary = new Cat("Gary", "Domestic Shorthair");
Cat.prototype.meow=function(){
console.log("Meow!");
};
cat.meow();


#2

cat is undefined. Were we to write, Cat.meow() it would raise an exception something like,

Cat has no attribute or method, `meow()`.

We would never call the constructor to run a method. Create an instance and call the method on that object.

Try with 'cheshire' or 'gary'...

gary.meow();

#3

Ugh Thank you. The instructions of each of these lessons are killing me.


#4

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