15/30 - 3 ways to "succesfully" complete the section but only one right answer. Why?


The true correct answer was this follow blipet of code::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(){

// add code here to make the cats meow!
//This above code and it's multiple ways to successfully complete the section caused me a lot of unanswered questions.

However, I initially did

It returned [function] [function] respectively.

Then I played around and did

This returned a blank console but allowed me to pass.
I am assuming that since I didn't recall it as a method, It didn't go through to the console.log portion of the earlier bit where we defined the method?

I would just like to know the differences in the 3 ways they pass and why they work even though only one is truly correct. Thank you for your help.


It returned [function] because you wrote a reference, not an invocation (call expression)...

gary.meow  => function reference

Were we to write,


we would get,


However, invoking the method, we get

gary.meow(); // Meow!

Hope that answers your question.


Thank you very much for this.