Constructors in review 25- question


My code passes when I run it however after each rabbit is printed out to the console it also prints out "Undefined" under each rabbit description?? Just curious why it is doing this? anyone have any suggestions? 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");
var rabbit2 = new Rabbit("happy");
var rabbit3 = new Rabbit("sleepy");

//print out something about your rabbits
console.log (rabbit1.describeMyself());
console.log (rabbit2.describeMyself());
console.log (rabbit3.describeMyself());


Hey @dthden66! Thats cause you didnt call the method it self. This should work(Without the console.log):

var rabbit1 = new Rabbit();
rabbit1.adjective = "fluffy"

var rabbit2 = new Rabbit();
rabbit2.adjective = "happy"

var rabbit3 = new Rabbit();
rabbit3.adjective = "sleepy"


Thanks amanuel2, I see now what I did wrong. No need for me to be using console.log as the method already includes it, just needed to call the method properly..

Thanks!!, code works fine now


I am misunderstanding why calling the constructor with the parameter of "fluffy", "happy", "sleepy", etc does not work. I see that rabbit1.adjective = "fluffy" would work. However why wouldn't the var rabbit1 = new Rabbit("fluffy"); work? Thanks for your time!


I used and pass, excellent! Thank you very much!