Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
runas24 authored Apr 19, 2024
1 parent d501ab4 commit 90de7d3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ document.getElementById("monthlyPaymentForm").addEventListener("submit", functio

var loanAmount = parseFloat(document.getElementById("loanAmount").value.replace(/\D/g, ''));
var annualInterestRate = parseFloat(document.getElementById("annualInterestRate").value);
var loanTerm = parseInt(document.getElementById("loanTerm").value);
var loanTermInYears = parseInt(document.getElementById("loanTermInYears").value);

// Рассчитываем ежемесячный платеж
// Рассчитываем ежемесячную процентную ставку и количество платежей
var monthlyInterestRate = annualInterestRate / 100 / 12;
var numberOfPayments = loanTerm * 12;
var numberOfPayments = loanTermInYears * 12;

// Рассчитываем ежемесячный платеж
var monthlyPayment = (loanAmount * monthlyInterestRate) / (1 - Math.pow(1 + monthlyInterestRate, -numberOfPayments));

// Выводим результат
Expand Down

0 comments on commit 90de7d3

Please sign in to comment.