javascript, Dicoding

Run Settings
LanguageJavaScript
Language Version
Run Command
function Car(manufacture, color) { this.manufacture = manufacture; this.color = color; this.enginesActive = false; } Car.prototype.startEngines = function () { console.log('Mobil dinyalakan...'); this.enginesActive = true; }; Car.prototype.info = function () { console.log("Manufacture: " + this.manufacture); console.log("Color: " + this.color); console.log("Engines: " + (this.enginesActive ? "Active" : "Inactive")); } var johnCar = new Car("Honda", "Red"); johnCar.startEngines(); johnCar.info()
class Car{ constructor(manufacture, color){ this.manufacture = manufacture; this.color = color; this.enginesActive = false; } startEngines(){ console.log('mobil dinyalakan..'); this.enginesActive = true; } info(){ console.log(`Manfacture: ${this.manufacture}`); console.log(`color : ${this.color}`); console.log(`Engines: ${this.enginesActive ? "Active" : "Inactive"}`); } } const johnCar = new Car ("Honda", "Red"); johnCar.startEngines(); johnCar.info();
Editor Settings
Theme
Key bindings
Full width
Lines