25.Oops, try again. Make sure you created rabbit1, rabbit2 and rabbit3



popup window:Oops, try again. Make sure you created rabbit1, rabbit2 and rabbit3
console:TypeError: Rabbit1.Rabbit is not a function

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 Object();
Rabbit1.describeMyself( );

var Rabbit2 = new Object();
Rabbit1.describeMyself( );

var Rabbit3 = new Object();
Rabbit1.describeMyself( );

what is wrong, I do not get it


From instructions:

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".

So, you need create rabbit1 NOT Rabbit1. Your Rabbit constructor defines an adjective property and a describeMyself method. When you want to create new rabbit object you just need put argument for adjective property:

var rabbit1 = new Rabbit("fluffy");

If you want to use Object constructor:

var rabbit1 = new Object(); //  base Object constructor
rabbit1.adjective = "fluffy";

In your case


you try to call Rabbit method which isn't defined in Rabbit constructor.

If you use basic constructor you create new object without any properties and methods. So, you created 3 empty objects and tried to call not defined methods.

When you use own constructor you need to use new Rabit() constructor and put there argument "fluffy" (because your constructor has one parameter).

var rabbit1 = new Rabbit("fluffy"); // own Rabbit constructor

It means that you created new Rabbit object rabbit1 and assigned for property adjective value "fluffy". Then you need to call _describeMyself() _ method defined in your constructor.


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