class RentalUnit { constructor(address, costPerYear) { this._address = address; this._costPerYear = costPerYear; } get address() { return this._address; } get costPerYear() { return this._costPerYear; } calculateMonthly() { return this.costPerYear / 12; } } class Apartment extends RentalUnit { constructor(address, costPerYear, numberOfBedrooms) { super(address, costPerYear); this._numberOfBedrooms = numberOfBedrooms; } get numberOfBedrooms() { return this._numberOfBedrooms; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter