Last active
March 18, 2021 11:28
-
-
Save parasdaryanani/f646f3389489c2b452d2e38549df161e to your computer and use it in GitHub Desktop.
Calculate Profit using a generic pipe function
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
const pipe = (...fns) => arg => fns.reduce((value, fn) => fn(value), arg); | |
const calculateProfit = pipe( | |
// Deduct EU VAT (0.20) | |
value => value * (1 - 0.2), | |
// Deduct corporation tax (0.20) | |
value => value * (1 - 0.2), | |
// Add external contributions | |
value => value + 2500, | |
// Split with 0 co-founders | |
value => value / 3, | |
); | |
// console.log(calculateProfit(1000)) | |
// 1046.67 | |
export default calculateProfit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment