JSFiddle - React, Tailwind, and code Playground
by Yuriy Bablyukh
JavaScript
function Automobile(name) {
this.name = name;
this.canTrive = true;
this.fuel = 20;
this.wheelsNumber=4;
this.speed=80;
this.fuelСonsumption=5;
this.getDistance = function(n) {
return this.fuel/this.fuelСonsumption*100;
}
}
function Car(name) {
this.fuel=30;
this.passengersSeats=4;
this.capacityTank=50;
this.maxSpeed=185;
this.name=name;
}
function Truck(name) {
this.passengersSeats=2;
this.fuelСonsumption=10;
this.speed=60;
this.capacityTank=100;
this.maxSpeed=150;
this.name=name;
}
Car.prototype = new Automobile();
Truck.prototype = new Automobile();
ford = new Car('Ford');
reno = new Truck('Reno');
console.log(ford.name);
console.log(reno.name);