JSFiddle - React, Tailwind, and code Playground
by vysohanych
JavaScript
function Car(brand) {
this.brand = brand;
this.drive = true;
this.fuel = 40;
this.wheels = 4;
this.speed = 120;
}
function passengerCar(brand) {
this.brand = brand;
this.passengers = 5;
this.fuel = 60;
this.speed = 240;
this.wheels = 4;
}
function Camion(brand) {
this.brand = brand;
this.passengers = 3;
this.fuel = 200;
this.speed = 160;
this.wheels = 8;
}
passengerCar.prototype = new Car();
var audi = new passengerCar("AUDI");
console.log("Brand: " + audi.brand + ", can it drive?: " + audi.drive + ", number of passengers: " + audi.passengers + ", full fuel: " + audi.fuel + ", max speed: " + audi.speed + ", number of wheels: " + audi.wheels);
Camion.prototype = new Car();
var volvo = new Camion("VOLVO");
console.log("Brand: " + volvo.brand + ", can it drive?: " + volvo.drive + ", number of passengers: " + volvo.passengers + ", full fuel: " + volvo.fuel + ", max speed: " + volvo.speed + ", number of wheels: " + volvo.wheels);