Constructors in review (Needs Debugging)


#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 = Rabbit("fluffy");
var rabbit2 = Rabbit("happy");
var rabbit3 = Rabbit("sleepy");
console.log(rabbit1);
console.log(rabbit2);
console.log(rabbit3);


#2

You need to use your constructor you made at the top, do this by using the keyword new before each rabbit. After you do that you need to call the describeMyself function after each rabbit. describeMyself();.


#3

Hey! Thanks again! You're a lifesaver!


#4

All good, there were no bugs in this code. Just remember that you wrote this code at the top for a reason :slight_smile:


#5

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