Hello guys,

I am learning JS - left lot what to learn…

Now I try to make calculator, witch calculate the result, witch I get after some years and show linear in chart (chart works).

In a forms I enter amount of money, witch I will pay periodically, choose periods (annually, quarterly, two times a year, monthly).

Then I enter the number of years for how long I want to invest.

And finally I enter rates.

Lets say:

I invest for two years, invest 100 Eur monthly with 8% rates.

So after 1 year I invested 1200 Eur. and should have 1296 Eur.

After 2nd years I should have 2695.68 Eur. (1296 (from 1st year) + 1200 (invested monthly) + rates).

I try to find what I wrote wrong in a code (and formula), that its calculating bad results (and chart appears bad - by bad results of calculating).

Could you please check my function code:

```
function calculateGrowth(e) {
e.preventDefault();
data.length = 0;
labels.length = 0;
let growth = 0;
try {
const amount = parseInt(Amount.value);
const period = parseInt(years.value);
const interest = parseInt(rates.value);
const comp = parseInt(compound.value);
for(let i = 1; i <= period; i++) {
const final = (amount * comp / 100 * interest, comp * i);
data.push(toDecimal(final, 2));
labels.push("Year " + i);
growth = toDecimal(final, 2);
}
//
message.innerText = `You will get ${growth} Eur. after ${period} years`;
drawGraph();
} catch (error) {
console.error(error);
}
}
```

I think the problem is in my formula…

Or you know easier way to calculate thing what I want and you recommend me to change my function somehow?!

P.S. I was googling, tried another formulas with no right result.