Skip to content

Instantly share code, notes, and snippets.

@grahaml
Last active July 26, 2016 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahaml/e543283e3b37ac65a2f652d1a8054b24 to your computer and use it in GitHub Desktop.
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)
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,
};
@grahaml
Copy link
Author

grahaml commented Jul 26, 2016

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment