Last active
July 26, 2016 10:43
-
-
Save grahaml/e543283e3b37ac65a2f652d1a8054b24 to your computer and use it in GitHub Desktop.
A couple of simple functions to calculate the total cost of buying a used car in Ontario (with ability to add a percentage based buffer)
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 addTax = (price, tax) => price + (price * tax); | |
const addOntarioTax = (price) => addTax(price, 0.13); | |
const addLicensingCost = (price) => (price + 20 + 40 + 108); | |
const addBuffer = (price, buffer = 0) => (price + (price * buffer)); | |
const calculateTotalCost = (price, buffer) => Math.round(addBuffer(addLicensingCost(addOntarioTax(price)), buffer)); | |
module.exports = { | |
calculateTotalCost, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to buy a car for 10000, then the retail price needs to be ~8500. Once you add the tax and licensing fees it adds up...