Created
October 25, 2023 14:06
-
-
Save daryl-sf/923881cf9be8cfd8751e4cb0065a9471 to your computer and use it in GitHub Desktop.
Quick and Dirty interest calc
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
const interestCalc = (init, rate, years) => { | |
const pot = [...Array(years).keys()].reduce((acc, c) => { | |
const earnings = acc * rate; | |
acc += earnings; | |
console.log(`Earnings: £${earnings.toFixed(2)}, New Total: £${acc.toFixed(2)}`); | |
return acc; | |
}, init); | |
console.log(`Total: £${pot.toFixed(2)}. Total Earned: £${(pot - init).toFixed(2)}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment