-
-
Save devotdev/44bb539599e8f47582636ddc55241cff to your computer and use it in GitHub Desktop.
Multi-step calculation example
This file contains hidden or 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 calculateFinalPrice = function(basePrice, taxRate, discount) { | |
| const applyTax = function(price, rate) { | |
| return price + price * rate; | |
| } | |
| const applyDiscount = function(price, discount) { | |
| return price - discount; | |
| } | |
| let priceWithTax = applyTax(basePrice, taxRate); | |
| let finalPrice = applyDiscount(priceWithTax, discount); | |
| return finalPrice; | |
| } | |
| console.log(calculateFinalPrice(100, 0.2, 10)); // Output: 110 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment