Here is another example for understanding the exercise>
var Person = function(){
this.name;
this.age;
this.high;
this.color;
}
var employee = new Person();
employee.name = "Sousa Gaspar";
alert(employee.name)
var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 5;
};
// Only change code below this line.
var myCar = new Car();
myCar.nickName = "This is Rose";
The playground give this alert, “The property nickname of myCar should be a string.”, what am I doing wrong?
nickname and nickName are two different properties.
The challenge asks you to use Car() as a constructor for myCar (see @sgenio’s post above for an example of using a constructor). What you’ve done is created a new constructor called myCar. A constructor is a function used to create objects, and the properties set with the this keyword within the constructor aren’t properties of the constructor itself; instead, they become properties of objects created using the constructor. To create objects using a constructor, you use the new keyword.