程序需要产生用于一个随机数presentValue,months和 interest%之间率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)
你需要传递参数:
console.log(futureValue())
Run Code Online (Sandbox Code Playgroud)
至
console.log(futureValue(presentValue,interest,months))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
53 次 |
| 最近记录: |