【问题标题】:how to calculate mortgage in javascript如何在javascript中计算抵押贷款
【发布时间】:2013-06-10 16:29:22
【问题描述】:

我有四个字段查找每月付款的公式

  1. 贷款金额
  2. 利率
  3. 贷款条款
  4. 每月付款

Formula: Monthly Payment =Loan amount * ((1 + Interest rate per annum/100) ^ Term of loan) / Term of loan / 12

现在我想找到

  1. 贷款金额
  2. 利率
  3. 贷款条款

如果填充了三个字段中的任何一个。

我还有根据利率、贷款条款和每月还款额计算贷款金额的公式。

Formula: Loan amount = Monthly Payment/ ((1 + Interest rate per annum/100) ^ Term of loan) * Term of loan * 12

但它不计算完美的数字。

任何人都可以给我这三个计算贷款金额/利率/贷款条件的公式(java脚本将更加感激)

【问题讨论】:

  • 但是那个公式的 JavaScript 代码在哪里?什么不工作?
  • 你已经有了公式。将其转换为代码并不难,您是否需要解决更具体的问题?
  • 我想根据从四个字段填充的三个字段查找任何字段。所以我想要四个公式。 1)对于我拥有并且正在工作的每月付款 2)对于贷款金额公式 3)对于利率公式和 4)对于贷款条款

标签: javascript math formula


【解决方案1】:

这是我的,

公式:

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

nerdWallet

希望这能有所帮助

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);
}

【讨论】:

  • 如果兴趣为 0,这不起作用。我知道这是一种罕见的情况,但一个完美的功能应该涵盖它
  • 这与我在这里看到的不符:calculator.net/…
【解决方案2】:
var deno = (100 + Interest_rate_per_annum)/100;
var pdeno = Math.pow(deno, Term_of_Loan);
var loan_amount = (Monthly_payment * Term_of_Loan * 12) / pdeno;

【讨论】:

    【解决方案3】:

    这与@shay 给出的答案完全相同,但拼写了变量名称以便我更容易理解:

    // totalPayments should be the total number of payments expected to be made for the life of the loan: years * 12
    // interestRate: eg. 6.2% should be passed as 0.062
    function getMortgagePayment(startingLoanAmount, totalPayments, interestRate)
    {
        let interestRatePerMonth = interestRate / 12;
        return startingLoanAmount * interestRatePerMonth * (Math.pow(1 + interestRatePerMonth, totalPayments)) / (Math.pow(1 + interestRatePerMonth, totalPayments) - 1);
    }
    

    【讨论】:

      猜你喜欢
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-13
      • 2015-06-30
      • 2012-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多