Hi All!

I am new to Javascript, and coding in general, and I am trying to make a simple loan amortization table to cement my study so far.

But, I am unsure as to the best way to input the formula I need into my code. I am receiving error messages associated with that line of code in the console (Uncaught SyntaxError: Unexpected token ; ).

I figure that I must be making an error in how I am writing out the formula. I am trying to put this into the function:

monthlyPayment = principal * ( monthlyInterest / (1 - (1 + monthlyInterest) ^ -numberOfMonths))

I tried using the Math.pow( , ) function, but may be getting messed up there. In general, I would really appreciate feedback on this code- first time independently trying to make anything in Javascript. Many Thanks!

Code:`var principal= 100000`

var annualInterest = 5

var lengthYears= 15

function monthlyPayment (principal, annualInterest, lengthYears){

var monthlyInterest = annualInterest/(12*100);

var numberOfMonths = lengthYears*12;

var monthlyPayment = principal * ((monthlyInterest/(1-Math.pow((1+monthlyInterest)), (-1*numberOfMonths)));

return monthlyPayment;

}

while (principal> 0){

monthlyInterest = (principal*monthlyInterest);

var principalPayment = (monthlyPayment-monthlyInterest);

var newBalance = (principal-principalPayment);

principal = newBalance;

}