Simple class

by REPLY2SAGAR

JavaScript

class Car {
    constructor(brand, model) {
        this.brand = brand;
        this.model = model;
    }

    display() {
        console.log(`This car is a ${this.brand} ${this.model}.`);
    }
}

// Creating an instance of Car
let myCar = new Car("Toyota", "Corolla");
myCar.display();  // Outputs: This car is a Toyota Corolla.