Skip to content

Instantly share code, notes, and snippets.

@FagnerMartinsBrack
Created January 9, 2018 01:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FagnerMartinsBrack/fa8fb9b32e71e597901258340d4936a8 to your computer and use it in GitHub Desktop.
Save FagnerMartinsBrack/fa8fb9b32e71e597901258340d4936a8 to your computer and use it in GitHub Desktop.
(Medium) Incremental Delivery
// 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