-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (25 loc) · 790 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
var Mortgage = require('./mortgage');
var print = require('node-print');
var amount = 96000;
var interest = 0.03875;
var years = 20;
var afterMonths = 6;
var mortgage = new Mortgage(amount, interest, years);
var payment = mortgage.fixedMonthlyPayment();
var remaining = mortgage.remainingLoanBalance(afterMonths);
var amortTable = mortgage.amortizationTable();
var amortList = amortTable.map(function (row, i) {
return {
'Month': i,
'Payment': row[0],
'Principal Paid': row[1],
'Interest Paid': row[2],
'Total Interest': row[3],
'Balance': row[4]
};
});
console.log('Fixed monthly payments: ' + payment);
console.log('Remaining balance after ' + afterMonths + ' months: ' + remaining);
console.log('Amortization table:');
print.pt(amortList);