Prototype Practice. Can pass, but something is.. odd


#1


https://www.codecademy.com/en/courses/objects-ii/2/5?curriculum_id=506324b3a7dffd00020bf661

I am able to pass the section with the code below, but I do not know why the console is not printing anything from the for loop (the loop passes the exercise by itself even though nothing is printing).


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!
for (var i = Cat[0]; i < Cat.length; i++){
    Cat.meow();
} // works (in the sense that it "passes" the section even with the items below removed), but nothing is printed to console when I try to print this way. Why? Same if I use for/in. 

cheshire.meow(); //works and logs to console
gary.meow(); //works and logs to console


#2

Cat is an Object constructor (A function) not an Array or Object ?


#3

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