Am I supposed to get "undefined" in lesson 25?


I am getting "undefined" after every console.log() I make. Where is it coming from ?

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


The output, undefined is the console response to a function call with no return value. Consider that console.log() does not have a return value. If we log it, we get,

    console.log(console.log());    // undefined

This is what is happening above since you are logging console.log()


Since the method is logging, try just calling it on the object:



A post was split to a new topic: Everything working the way it was supposed to


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