1
我需要一個函數來計算抵押年金分期付款表,其中包括支付金額,本金,利息支付等行和列的輸出,按照如下鏈接按月排序: Output exampleJavaScript中的年金攤銷表
輸出文件格式應該是.cvs。目前,我堅持這個女巫還是遠離結果:
var i = 5/100;
var loanAmount = 15000;
var m = 12;
var monthlyPayment = loanAmount*(i/12)*Math.pow((1+i/12), m)/(Math.pow((1+i/12), m)-1)
var currentBalance = loanAmount;
var paymentCounter = 1;
var totalInterest = 0;
monthlyPayment = monthlyPayment;
\t \t
while(currentBalance > 0) {
//this calculates the portion of your monthly payment that goes towards interest
towardsInterest = (i/12)*currentBalance;
\t \t
if (monthlyPayment > currentBalance){
monthlyPayment = currentBalance + towardsInterest;
}
\t \t
towardsBalance = monthlyPayment - towardsInterest;
totalInterest = totalInterest + towardsInterest;
currentBalance = currentBalance - towardsBalance;
}
會很感激有這方面的幫助。
你想讓我們做什麼?爲你寫代碼? 你可以提到你被卡住的確切位置 –