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!
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

Ossian MacDonald
2,175 PointsTrouble with Math.pow
HI All,
I am having trouble with the math.pow function. I am trying to replicate this formula:
monthlyPayment = principal * ( monthlyInterest/ (1 - (1 + monthlyInterest) ^ -numberOfMonths))
But, the number that I get from this calculation is far too small. So, I think that I am not writing the formula correctly in JS. I would really appreciate you taking a look at the relevant code:
Thanks so much!
1 Answer

James Barnett
39,199 PointsWhen using a function you need parentheses around the arguments Math.pow(argX, argY)
. So in your case that would be Math.pow(1+monthlyInterest, -numberOfMonths)
Also you forgot to end a few lines with semi-colons.
There's a JavaScript syntax checker built into codepen called JSHint, press ctrl+shift+7
to show JSHint messages and ctrl+shift+8
to hide JSHint messages.