Excel PMT function in JS

前端 未结 3 660
-上瘾入骨i
-上瘾入骨i 2021-02-06 04:07

I found i little snipet on internet, about PMT calculate.

function PMT(i, n, p) {
 return i * p * Math.pow((1 + i), n) / (1 - Math.pow((1 + i), n));
}
function C         


        
3条回答
  •  星月不相逢
    2021-02-06 04:23

    NaN means "Not A Number".

    Make sure you check for each input value whether it is numeric. Throw an error message if one is not, or set it to 0, depending on whether it's essential to your calculation or not.

    A good collection of the best ways to check a value for whether it's numeric is this SO question: Validate numbers in JavaScript - IsNumeric()

提交回复
热议问题