Created
January 9, 2018 01:53
-
-
Save FagnerMartinsBrack/fa8fb9b32e71e597901258340d4936a8 to your computer and use it in GitHub Desktop.
(Medium) Incremental Delivery
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
// Usage: Copy this code and run in a ES6 capable Browser Console | |
function profitFrom({ sell, buy }) { | |
const profit = sell - buy; | |
return (100 * profit / buy) + '%'; | |
} | |
console.log(`${profitFrom({ buy: 50, sell: 50 }) === '0%' && 'PASSED' || 'FAILED'}: No profit or loss for break even`); | |
console.log(`${profitFrom({ buy: 50, sell: 100 }) === '100%' && 'PASSED' || 'FAILED'}: Profit`); | |
console.log(`${profitFrom({ buy: 100, sell: 50 }) === '-50%' && 'PASSED' || 'FAILED'}: Loss`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment