Skip to content

Instantly share code, notes, and snippets.

@1-800-jono
Created October 22, 2017 15:29
Show Gist options
  • Save 1-800-jono/adff06fba3f4ea5e2585a54f9987e8dc to your computer and use it in GitHub Desktop.
Save 1-800-jono/adff06fba3f4ea5e2585a54f9987e8dc to your computer and use it in GitHub Desktop.
JS function to calculate car depreciation rate based on 14% rate
function calculateDepreciation(startPrice, years) {
for (i = 1; i <= years; i++) {
const result = startPrice * Math.pow((1 - 14/100), i);
console.log(Math.round(result).toLocaleString('en'))
}
}
calculateDepreciation(29000, 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment