Meow!


#1

This is my code and i dont understand why it doesnt work. I want it to Meow! :slight_smile:

function Cat(name, breed) {
this.name = name;
this.breed = breed;
}

// let's make some cats!
var cheshire = new Cat("Cheshire Cat", "British Shorthair");
var gary = new Cat("Gary", "Domestic Shorthair");

// add a method "meow" to the Cat class that will allow
// all cats to print "Meow!" to the console
Cat.prototype.meow = function {
console.log("Meow!");
};

// add code here to make the cats meow!
cheshire.meow();
gary.meow();


#2

Your syntax isn't valid, that code will not run and therefore also not.. meow


#3

Cat.prototype.meow = function () { // was missed ()
   console.log("Meow!");
};

#4

I have just added "()" and it works. And I am very happy now. :slight_smile:
Thx


#5

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