Last active
October 20, 2017 08:03
-
-
Save dashawk/d503302bb17e5769add97fe5fd59ea02 to your computer and use it in GitHub Desktop.
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
//region Get the Margin | |
var cost = 5; | |
var sell = 10; | |
var margin = 0; | |
// Original Formula | |
margin = ((sell - cost) / sell) * 100; | |
console.log('[Original]Margin', margin); | |
// Shorthand Formula | |
margin = (1 - (cost / sell)) * 100; | |
console.log('[Shorthand]Margin', margin); | |
//endregion | |
//region Get the Sell | |
var cost = 5; | |
var sell = 0; | |
var margin = 50; // 50% | |
// Original Formula | |
sell = cost / (1 - (margin / 100)); | |
console.log('[Original]Sell', sell); | |
//endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment