...

/

Solution: Getting Classy

Solution: Getting Classy

Review a solution to the task from the getting classy challenge.

We'll cover the following...

Solution

Here is a possible solution for implementing car classes:

Press + to interact
class Car {
constructor(make, model) {
this.make = make;
this.model = model;
}
}
class ElectricCar extends Car {
constructor(make, model, range) {
super(make, model);
this.range = range;
}
}
// Create an instance of ElectricCar
const electricCar = new ElectricCar('Tesla', 'Model 3', 250);
console.log(electricCar.make);
console.log(electricCar.model);
console.log(electricCar.range);

Explanation

  • Line 1: Defines a class called Car.

  • ...