Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Objects Prototypes

Nazaam Kutisha
Nazaam Kutisha
7,667 Points

Help with Challenge

Challenge task 1 of 3

Modify the 'Car' constructor function so that it takes an argument for its model and set its 'model' to the model passed in from the argument.

    <script>


      var carPrototype = {
        model: "generic",
        currentGear: 0,
        increaseGear: function() {
          this.currentGear ++;
        },
        decreaseGear: function() {
          this.currentGear--;
        } 
      }

      function Car(model) {
        this.model= generic;


      }

      car.prototype= carPrototype;


    </script>

4 Answers

Laura Cressman
Laura Cressman
12,548 Points

Looks good, except for one tiny thing. You are setting this.model to "generic" in the body of your function definition. Instead, use the model parameter you passed in, so the body says this.model = model; instead of this.model = generic;. Let me know if that helps! Smile:) Laura

Nazaam Kutisha
Nazaam Kutisha
7,667 Points

Hi Laura,

Brilliant! its always the little things. This code worked for the challenge.

``` function Car(model) {

this.model = model;

}

Many Thanks
Laura Cressman
Laura Cressman
12,548 Points

No problem, fresh eyes can certainly be useful! :)

J Scott Erickson
J Scott Erickson
11,883 Points

You need to set Car.prototype = carPrototype;

and also as the previous poster said: this.model = model; in your constructor.

Nazaam Kutisha
Nazaam Kutisha
7,667 Points

That helped a lot js can kind of leave you hanging. Great responses ...