Created
August 22, 2022 09:00
-
-
Save 1FahadShakeel/ceddd7c74f0675ac351985756cc6950d to your computer and use it in GitHub Desktop.
compound interest with regular intervals
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
let princ = 10000; // start deposit | |
let add = 500; // monthly deposit (need plus it every year) | |
let rate = 0.06; // interest rate divided to create decimal | |
let months = (41 * 12); //41 years of monthly contributions | |
for (let i = 1; i <= months; i++) { | |
princ += princ * (rate / 12); | |
princ += add; | |
console.log(princ); | |
} | |
console.log(princ.toFixed(2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment