class Item {
constructor(name, price) {
//... // Constructor Implementation
this.name = name;
this.price = price;
}
}
class SaleItem extends Item {
constructor(name, price, discount) {
super(name, price);
this.discount = discount;
//...//Constructor Implementation
}
}
let regItem =new Item('Scarf', 55);
let saleItem = new SaleItem('Shirt', 80, -1);
Item.prototype.description = function () {
return 'This is a ' + this.name;
}
console.log(regItem.description());
console.log(saleItem.description());
SaleItem.prototype.description = function () {
return 'This is a discounted ' + this.name;
}
console.log(regItem.description());
console.log(saleItem.description());
https://onecompiler.com/javascript/3ynjm3tf9