how to calculate mortgage in javascript

后端 未结 3 949
执念已碎
执念已碎 2021-02-06 11:13

I have formula for finding monthly payment with four fields

  1. Loan Amount
  2. Interest Rate
  3. Terms of loan
  4. Monthly Payment

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-06 11:55

    Here is mine,

    the formula :

    M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
    

    nerdWallet

    Hope this helps in someway

    var M; //monthly mortgage payment
    var P = 400000; //principle / initial amount borrowed
    var I = 3.5 / 100 / 12; //monthly interest rate
    var N = 30 * 12; //number of payments months
    
    //monthly mortgage payment
    M = monthlyPayment(P, N, I);
    
    console.log(M);
    
    function monthlyPayment(p, n, i) {
      return p * i * (Math.pow(1 + i, n)) / (Math.pow(1 + i, n) - 1);
    }

提交回复
热议问题