Constructors In Review


#1



https://www.codecademy.com/courses/spencer-sandbox/3/6?curriculum_id=506324b3a7dffd00020bf661#


So, the following code worked, but before it worked, Rabbit1, Rabbit2, and Rabbit3 all had capital R's. Why was that a problem? Thanks.


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');


#2

@bj77,
In this lesson the code-checker
is testing on the variables rabbit1, rabbit2 and rabbit3

The code-convention for a variable
starts with a lowercase-character
in javascript they use camel-style like carFactoryEntranceSecurity
http://javascript.crockford.com/code.html <---JavaScript code-convention


#3

This worked for me:
var rabbit1 = new Rabbit ("fluffy");
rabbit1.describeMyself(rabbit1);

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

var rabbit3 = new Rabbit ("sleepy");
rabbit3.describeMyself(rabbit3);

PS: there is a closed topic that gives guidance on this.