25. Constructors in review


#1


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


My code passes, but prints "undefined" to the console between each of the rabbit descriptions and I don't understand why. Any ideas?


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

Each time you call describeMyself you are calling console.log twice, see that? In one of the cases you aren't thinking about what value it is you're logging.


#3

Perfect! Thank you, just didn't read the pre-written code properly.


#4

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