Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

[SOLVED] Javascript question

Somebody please tell me what I'm doing wrong. Here is the question and my answer on the bottom:

Create a new object rabbit1 with the adjective "fluffy", a new object rabbit2 with the adjective "happy", and a new object rabbit3 with the adjective "sleepy".

Use the method describeMyself to print out in the console a sentence about each object you just created!

function Rabbit(adjective) {
      this.adjective = adjective;
      this.describeMyself = function() {
              console.log("I am a " + this.adjective + "rabbit");
          };
}


var rabbit1 = new Rabbit(fluffy);
var rabbit2= new Rabbit(happy);
var rabbit3= new Rabbit(sleepy;

rabbit1. describeMyself();
rabbit2.describeMyself();
rabbit3.describeMyself();

Darn it I just solved the problem. I was suppose to make whats in the parameters a string."" Thanks anyway for looking into it who ever you are

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,254 Points

It looks like you've got a space between rabbit1 and your function call as well... i don't know if you fixed that one as well. :-)

Marked as solved

Glad you solved this, Gary!

Also, the space you're referring to Jonathan between the = and rabbit1 won't have any effect at all on the code. There's no space in between the function call, either.

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,254 Points

I was referring to the third line from the bottom Marcus :-) I'm certain the line needs the variable rabbit1 and the function describeMyself() to be joined by the full stop.

rabbit1. describeMyself();

becomes

rabbit1.describeMyself();

Ah apologies! I didn't even see that haha :D Good catch, Jon!