JSFiddle - React, Tailwind, and code Playground

JavaScript

function Car (color, brand) {
this.color = color;
this.brand = brand;
}

Car.prototype.result = function() {
console.log('Поздравляем, Ваша машина марки: ' + this.brand + ' ' + this.color + ' цвета способна ехать со скоростью '
+ this.maxspeed + 'км/ч' + ' и ' + 'она у вас ' + this.doors + '-x дверная');
};

Car.factory = function(type, color, brand) {
var constr = type,
newcar;
if(typeof Car[constr] !== 'function') return;
if(typeof Car[constr].prototype.result !== 'function') {
Car[constr].prototype = new Car(color, brand);
}
newcar = new Car[constr]();
return newcar;
}

Car.BMW = function() {
this.maxspeed = 200;
this.doors = 4;
};

Car.PORSHE = function() {
this.maxspeed = 300;
this.doors = 2;
};

var bmw = Car.factory('BMW', 'красного', 'bmw');
bmw.result();
var Porshe = Car.factory('PORSHE', 'черного', 'porshe');
Porshe.result();