我收到一点奇怪的错误.
我试图随机选择一个数组的索引,所以为了做到这一点,我使用下面的代码:
myArray[Math.floor(Math.random*myArray.length)]
myArray.length是282,但是Math.floor(Math.random*myArray.length)NaN并且myArray[Math.floor(Math.random*myArray.length)是未定义的.
有什么想法吗?
Math.random 它应该是一个功能 Math.random()
尝试
myArray[Math.floor(Math.random()*myArray.length)]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
918 次 |
| 最近记录: |