javascript constructor
// Let's make a function that will accept parameters for our vehicle
function Car(maker, model, color, tireSize) {
// Now we will set the paramaters equal to the different attributes of the car
this.maker = maker;
this.model = model;
this.color = color;
this.tireSize = tireSize;
// Next we'll make a method that will give a dynamic description of our car
this.description = function() {
return "My car is a " + color + " " + maker + " " + model + " with " + tireSize + " inch tires."
}
}
// Now let's make a new car. I want the car to have these attributes:
let car1 = new Car("Kia", "Soul", "white", 15);
// Now we can print the description of out new vehicle to the console
console.log(car1.description());
// OUTPUT: My car is a white Kia Soul with 15 inch tires.