25. Constructors in Review


#1

function Rabbit(adjective) {
this.adjective = adjective;
this.describeMyself = function() {
console.log("I am a " + this.adjective + " rabbit");
};
}

// now we can easily make all of our rabbits
var rabbit1 = new Rabbit (fluffy);
var rabbit2= new Rabbit(happy);
var rabbit3 = new Rabbit (sleepy);
console.log(Rabbit1.describeMyself());
console.log(Rabbit2.describeMyself());
console.log(Rabbit3.describeMyself());

I don't know what i am doing wrong.


#2

Put quotes around "fluffy" and other parameters.
Rabbit1 is not the same as rabbit1.


#3

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