Introduction to Objects I Constructors in Review


#1

function Rabbit(adjective) {
this.adjective = adjective;
this.describeMyself = function() {
console.log("I am a " + this.adjective + " rabbit");
};
}
var rabbit1 = {
"fluffy"
};
var rabbit2 = {
"happy"
};
var rabbit3 = {
"sleepy"
};
// now we can easily make all of our rabbits
objectName.methodName(rabbit1);

please help me


#2

SyntaxError: Expected identifier
this is the problem I get


#3

You should use the constructor to make your Rabbits.

jeff = Rabbit("My name is Jeff");

#4

100% working

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");
rabbit1.describeMyself();