当我需要总数时生成NAN

Bra*_*ton 2 javascript nan

程序需要产生用于一个随机数presentValue,monthsinterest%之间率0.1-0.10.

在进行最终计算时,我得到了NaN.

var count = 5;

function futureValue(presentValue, interest, months) {
  var step1 = 1 + Number(interest);
  var step2 = parseFloat(Math.pow(step1, months));
  var step3 = presentValue * step2;
  return "The future value is: " + step3;
}

for (i = 0; i < count; i++) {
  var presentValue = Math.floor(Math.random() * 100)
  var interest = ((Math.random() * .10 - 0.1) + .1).toFixed(2)
  var months = Math.floor(Math.random() * 100)
  futureValue(presentValue, interest, months)
  console.log("The present value is: " + presentValue);
  console.log("The interest rate is: " + interest);
  console.log("The number of months is: " + months);
  console.log(futureValue());
}
Run Code Online (Sandbox Code Playgroud)

Ben*_*Ben 5

你需要传递参数:

console.log(futureValue())
Run Code Online (Sandbox Code Playgroud)

console.log(futureValue(presentValue,interest,months))  
Run Code Online (Sandbox Code Playgroud)