Everything working the way it was supposed to


Help please

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 = Rabbit("fluffy");
var rabbit2 = Rabbit("happy");
var rabbit3 = Rabbit("sleepy");

There's a problem,
I used this code, everything working the way it was supposed to. However, it showed this error next to the "save and submit button":
Oops, try again.
When checking rabbit1, your code caused the following error: TypeError: rabbits[i] is undefined

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

The above line does not belong inside the constructor function. Remove.

Unclear where that error is coming from, It implies a loop iterator. Perhaps it is related to errant line mentioned above.


ok, I fixed it. I forgot to put "new" in front of rabbit when using the constructor. Thanks for your help.

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


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