Constructors in Review


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/spencer-sandbox/3/6?curriculum_id=506324b3a7dffd00020bf661#

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I’m getting the error TypeError: Rabbit.describeMyself is not a function. (In ‘Rabbit.describeMyself(rabbit1)’, ‘Rabbit.describeMyself’ is undefined). What am I doing wrong?

```

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(Rabbit.describeMyself(rabbit1));

<do not remove the three backticks above>

#2

Hi @natalie11594 :smiley:
Your error is very simple, when you call the describeMyself() function, you’re calling it on the CLASS not the object.
Just switch the Rabbit call to one of your classes’ objects -> rabbit1.describeMyself();

Hope this helps!!!


#3

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