Consturctors in Review


#1

Hey... so I have my code and it lets me pass to the next exercise but the thing is that in the console it loggs [Function] three times in a row. I think a sentance should be show there instead of those [Function]s. Btw heres my code and let me know how to fix this. Thanks. ^.^

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

var rabbit2 = new Rabbit("happy")
    console.log(rabbit2.describeMyself)

var rabbit3 = new Rabbit("sleepy")
    console.log(rabbit3.describeMyself)

#2

Well rabbit3.describeMyself is a [Function] or rather a method but anyway what you would be more interesting than printing the function itself might be to call the function and print what gets returned:

console.log(rabbit3.describeMyself())


#3

So its not supose to print things like... "I am a fluffy rabbit"?


#4

It is, but therefore you need to call the function and print the result not to print the function:

console.log(rabbit3.describeMyself) //prints function
console.log(rabbit3.describeMyself()) //prints result of function call

#5

Okay understood. Thank you for your time. ^.^