I am working on a amortization schedule for a credit card loan. I keep getting one error or another when running the code I've written. It's "Unexpected identifier", to which I can't seem to locate where that is.
Please help me to straighten the code better so it will run the schedule
function displayWelcome() {
var balance = 1500;
var interest = 0.18;
var minimumpaymentRate = 0.02;
console.log("Welcome! \nThis program will determine the time to pay off
a
credit card and the interest paid based on the current balance, the
interest rate, and the monthly payments made.")
console.log("Balance on your credit card: $" + balance.toFixed(2))
console.log("Interest Rate: " + (interest * 100) + "%")
console.log("Assuming a minimum payment of 2% of the balance ($20 min)")
console.log("Your minimum payment would be: $" + minimumPaymentment)
console.log("\nYear Balance Payment # Interest Paid
Minimum Payment")
}
function calculateminimumPaymentment(balance, minimumPaymentRate) {
return Math.max(20, balance * minimumPaymentRate);
}
function generatePaymentId() {
var count = 0;
function paymentId() {
count ++;
return count;
}
return paymentId;
};
function processPaymentSchedule(balance, interest, minimumPayment) {
var id = generatePaymentId();
var year = 1;
var payments = 1;
var interestPaid = 0;
var yearChange;
while (balance > 0) {
yearChange = false;
if (payments % 12 == 0) {
year++
yearChange = true;
}
interestPaid += balance * interest / 12;
balance = Math.max(0, balance - (minimumPayment - balance * interest /
12));
minimumPayment = Math.max(20, balance * minimumPaymentRate);
payments++;
}
}
function displayPayment(pmt){
var pmt = {
balance: 1500,
minimumPaymentRate: 0.02,
interest: 0.18
console.log((yearChange ? year:" ") + " " + pmt.balance + "
"
+ payments + " " + pmt.interest + " " +
pmt.minimumPaymentRate);
return displayPayment
};
}
displayWelcome()
processPaymentSchedule(balance, interest, minimumPayment);
The expected results should be:
An amortization schedule that shows: Year, Balance, Interest
UPDATE:
I have updated with the suggestions listed below, but now am getting this error: