25. Constructor In Review


#1



https://www.codecademy.com/courses/spencer-sandbox/3/6?curriculum_id=506324b3a7dffd00020bf661#


It ouputs [Function] [Function] [Function] in the console despite passing me for the exercise. Is this a bug or did I do something wrong? I don't understand


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);


#2

Hi remenber that describeMyself its a method so you should call it with ()

.describeMyself()

and you dont need to use teh console.log() on them.


#3

i get it now. Thanks!


#5

`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");

this.describeMyself();`

it say concratulation but i see in console only this I am a [object Object] rabbit


#6

Hi you should not use this but the name of each rabbit and call the Method .describeMyself() on all of them , the first one is

rabbit1.describeMyself();

#7

thanks that worked.
i also tried this

var animal = [rabbit1.describeMyself(),rabbit2.describeMyself(),rabbit3.describeMyself()]

and also works but i wanted make less is more , cant imagine how to do


#8

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()
rabbit2.describeMyself()
rabbit3.describeMyself()