Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function estimatePrice(cost, action) {
- let profit = 50
- let subtotal = cost + profit
- action(subtotal)
- }
- function applyNormalVAT(subtotal) {
- console.log(subtotal * 1.21)
- }
- function applyReducedVAT(subtotal) {
- console.log(subtotal * 1.1)
- }
- function noVATApplied(subtotal) {
- console.log(subtotal)
- }
- estimatePrice(100, applyNormalVAT)
- estimatePrice(245, applyReducedVAT)
- estimatePrice(87, applyReducedVAT)
- estimatePrice(6, noVATApplied)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement