Question: Explain this code: class Car { //constructor constructor(Make, Model, Year, Milage, Color) { this.Make = Make; this.Model = Model; this.Year = Year; this.Milage = Milage;

Explain this code:

class Car {

//constructor

constructor(Make, Model, Year, Milage, Color) {

this.Make = Make;

this.Model = Model;

this.Year = Year;

this.Milage = Milage;

this.Color = Color;

}

driveToWork() {

console.log(`Old milage: ${this.Milage}, New milage: ${this.Milage + 33}`);

this.Milage += 33;

}

runErrands() {

console.log(`Old milage: ${this.Milage}, New milage: ${this.Milage + 30}`);

this.Milage += 30;

}

driveAroundTheWorld() {

console.log(`Old milage: ${this.Milage}, New milage: ${this.Milage + 24000}`);

this.Milage += 24000;

}

}

const car = new Car("Toyota", "Camry", 2015, 29, "Red");

car.driveToWork();

car.runErrands();

car.driveAroundTheWorld();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!