Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Loan Amortization Code Issues

Hi all!

I have been trying to make a very simple loan amortization loop, but I have some problems with it.

I can't seem to get the formula for the monthlyPayment variable down. The number right now is very small. I have tried using the math.pow function, so maybe I just haven't inputed the variables correctly. I am trying to replicate the formula at the top of this page: http://www.1728.org/loanform.htm

Perhaps because of this, the principal amount is actually going up-not down. I would really appreciate a review of this code so that I can see where I am going wrong- but also in general if there are areas where I can improve.

http://codepen.io/ossianmacdonald/pen/AyBpI

Thanks so much!