我有一个包含两个项目的数组,我需要随机选择这些项目,但大多数时候我从数组中得到相同的项目...
看代码:
var numbers = Array(523,3452); var choice = numbers[Math.floor(Math.random()*numbers.length)]; console.log("Choice:", choice);
我该如何避免这种行为?
javascript math node.js
javascript ×1
math ×1
node.js ×1