Last active
August 25, 2016 22:43
-
-
Save davidrhyswhite/e4270eb631cd250654b57268c5ce3a52 to your computer and use it in GitHub Desktop.
For the Medium article on Object.defineProperty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FinancialYear { | |
constructor(turnover, costOfGoods) { | |
this.turnover = turnover; | |
this.costOfGoods = costOfGoods; | |
Object.defineProperty(this, 'grossProfitMargin', { | |
get () { | |
const gpm = ((this.turnover - this.costOfGoods) / this.turnover) * 100; | |
return `${gpm}%`; | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment