The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript PMT Function Reply To: PMT Function


So, is the “future value” or “payment type” important to you? or can they be left out?

Looking at your codepen, I have to ask how much experience you have with javascript at all. Do you understand the basic syntax? how to define variables? how to pass values to functions?

Let’s start with the “skeleton” of a function. Here’s a quick rewrite of what you had: instead of hardcoding variable names and relying on them existing in the global scope, we will deliberately pass the values in when the function is called.

I also preserved your formula (except for the last 0, which caused a syntax error so I assumed it was a typo), using the new variable names. I don’t think the formula is correct, however. If you loaned me $10,000 at an 8.5% APR over 36 months, each payment would be approximately $5.2×10³⁶ (that’s 5.2 undecillion dollars. per month. for three years). Could you explain the formula?

I’m signing off for now, but I’ll check back in tomorrow.