tgoop.com/javascript/2200
Create:
Last Update:
Last Update:
CHALLENGE
function Device(name) {
this.name = name;
this.isOn = false;
}
Device.prototype.turnOn = function() {
this.isOn = true;
return `${this.name} is now on`;
};
function Smartphone(name, model) {
Device.call(this, name);
this.model = model;
}
Smartphone.prototype = Object.create(Device.prototype);
Smartphone.prototype.constructor = Smartphone;
Smartphone.prototype.turnOn = function() {
const result = Device.prototype.turnOn.call(this);
return `${result} (model: ${this.model})`;
};
const myPhone = new Smartphone('iPhone', '13 Pro');
console.log(myPhone.turnOn());
BY JavaScript
Share with your friend now:
tgoop.com/javascript/2200