Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

stuck on the prototypes

After the 'Car' constructor function, modify the Car's prototype to be the 'carPrototype'.

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


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

  Car.prototype = carPrototype;

I've tried all kinds of rearrangements and capitalizations, but to no avail. What am I doing wrong?

3 Answers

I passed it, but I don't see the difference between what you typed and what I did. What am I missing?

code example

thanks. In the prototype, I had model set to equal another variable OR 'generic'. i guess that threw the rest off

I see it now! Must have been it.

thanks

Hey Kevin Korte, you originally had your code like this.

 <p>Car.prototype = carPrototype();</p>

but you changed it to this

 <p>Car.prototype = carPrototype;</p>

firstworldproblems

I'm no JS expert by any means, and I'm not even sure where this test is, but I believe you have to use at least empty parentheses when calling a function even where there aren't any arguments to pass it.

So that would make it

Car.prototype = carPrototype();

it's not a function, it's referring to the object. I tried that and it didn't work, but thank you for trying to help.

You're right, reading that again, it's not a function. Duh. Is this a code challenge here? If so do you have a link? I'm curious to help figure it out.