Skip to content

Instantly share code, notes, and snippets.

@devotdev
Created December 18, 2024 09:30
Show Gist options
  • Save devotdev/44bb539599e8f47582636ddc55241cff to your computer and use it in GitHub Desktop.
Save devotdev/44bb539599e8f47582636ddc55241cff to your computer and use it in GitHub Desktop.
Multi-step calculation example
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