Constructors in Review


#1

function Rabbit(adjective) {
this.adjective = adjective;
this.describeMyself = function() {
console.log("I am a " + this.adjective + " rabbit");
};
}
var rabbit1 = new Rabbit("fluffy");
var rabbit2 = new Rabbit("happy");
var rabbit3 = new Rabbit("sleepy");

Why the console is not showing "I am a fluffy rabbit" "I am a happy rabbit" "I am a sleepy rabbit"?


#2

Because you didn't call describeMyself() method for rabbit1, rabbit2, rabbit3


#3

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