Make Unique Objects by Passing Parameters to our Constructor - help

Make Unique Objects by Passing Parameters to our Constructor - help
0.0 0

#1

Tell us what’s happening:
What wrong am i doing here?

Your code so far

var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(4, 6, 2);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0.

Link to the challenge:


#2

this.wheels = theArgumentYouArePassingToTheFunction and the same for the other two. It is the argument you pass to the function that you need to assign, not the number 4, otherwise wheels will always be 4 on each instance of Car


#3

Well, my reasoning is that var myCar is an instance of the var Car which I defined as something that takes in 3 arguments so if I do myCar(4, 6, 2); then it should automatically assign the relevant properties to my new Car instance.


#4

It only does that if you tell it to. Right now you are setting all Cars to have 4 wheels, 5 seats, and 1 engine.