JSFiddle - React, Tailwind, and code Playground

by wisegorilla

JavaScript

// this code simulate the profit from buying a certificate each month for 10 years
const monthlyInvest = 1000;
const period = 12;  // 120 months = 10 years
let currentBalance = 1000;
const monthlyInterest = 18 / 12;


for (let index = 1; index < period ; index++) {
  currentBalance += (currentBalance * monthlyInterest / 100 ) + monthlyInvest
  console.log(`Month no ${index}`, currentBalance);
}

console.log( currentBalance );