如何制作互惠基金 - SIP 计算器?

How to make Mutual Fund - SIP Calculator?

我正在为 website/blog 制作一个 SIP 计算器。但不知道我应该如何开始。我已经创建了一个基本的 html CSS 版本,但不知道如何计算数字。

  var investment = 800; //principal amount
  var annualRate = 2; 
  var monthlyRate = annualRate / 12 / 100;  //Rate of interest
  var years = 30; 
  var months = years * 12;  //Time period 
  var futureValue = 0; //Final Value

  futureValue = investment * (Math.pow(1 + monthlyRate, months) - 1) / 
monthlyRate;

SIP is nothing but just Compound interest amount on Principal amount.
$('#btn-sip').click(function(event) {

    var investment = $('#inv-amount').val(); // Total investment
    var years = $('#inv-period').val(); // No of years
    var annualRate = $('#inv-exreturn').val(); // annual Rate

        if (investment == '' || years == '' || annualRate == '') {
            alert('please enter all values');
        } else {
            var monthlyRate = annualRate / 12 / 100;
            var months = years * 12;
            var futureValue = 0;

        var total = ((investment*years*annualRate));

        futureValue=(investment * (1+monthlyRate) * ((Math.pow((1+monthlyRate),months)) - 1)/monthlyRate);

        $('#total-investment').val(Math.round(total));
        $('#end-value').val(Math.round(futureValue));

        $('#sip-cal-result').css('display', 'block');
        }
});