Lesson 25


#1

I get a 'Congratulations' for getting the code correct, yet I know the output is wrong because it logs:I am a fluffy rabbit all the times. Why are the 'sleepy' and 'happy' not showing up? Thanks.

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

var rabbit1 = new Rabbit("fluffy");
rabbit1.describeMyself();

var rabbit2 = new Rabbit("happy");
rabbit1.describeMyself();

var rabbit3 = new Rabbit("sleepy");
rabbit1.describeMyself();
// now we can easily make all of our rabbits

Here is the output:

I am a fluffy rabbit.
I am a fluffy rabbit.
I am a fluffy rabbit.


#2

It's because you have:

rabbit1.describeMyself();

After every new rabbit, if you want it to change to each rabbit, you'll have to change the function you're calling.


#3

Thanks! It's the most obvious things that seem to trip me up the most.