Passing Parameters to a Constructor
See original GitHub issueChallenge Waypoint: Make Unique Objects by Passing Parameters to our Constructor has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
var Car = function() {
//Change this constructor
this.wheels = 4;
this.seats = 1;
this.engines = 1;
};
//Try it out here
var myCar = new Car(3, 1, 2);
// Only change code above this line
(function() {return JSON.stringify(myCar);})();
I only modified the code within the // parameters and no matter the attempt I would get errors. I tried to pass parameters individually and would still receive errors. After asking for help on chat I was able to pass it, but not within the parameters set. I used multiple variations given, but none of them worked within the instructions. The constructor doesn’t appear to be able to be modified as is, the other people stated the same thing. Maybe the instructions weren’t as clear or this could be a bug. Error stated “Calling new Car(3,1,2) should produce an object with a wheels property of 3, a seats property of 1, and an engines property of 2.”
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
I don’t see what the problem is. The instructions are very clear
You need to change the code from
to
and then assign it to
var myCar
with the constructor.chat room doesn’t help a lot!!