Created
October 22, 2017 15:29
-
-
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
This file contains 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
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