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 JavaScript Foundations Objects Prototypes

Dan Neumann
Dan Neumann
Courses Plus Student 10,318 Points

Javascript Foundations 3rd Challenge task

In the prototype section in the 3rd challenge task, I put:

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

  Car.prototype = carPrototype;

  Car.prototype.wheels = "4";

and it returned Car.prototype.wheels was undefined not "4". Any ideas as to what I did wrong?

3 Answers

Hugo Paz
Hugo Paz
15,622 Points

carPrototype.wheels = 4;

Andrew Shook
Andrew Shook
31,709 Points

Yes, the problem is that you are using the old car prototype and not the one you established in step two of the challenge. Also, you need to set the number of wheel to a number and not a string. Hope this helps, if you need more of an explanation just let me know