select random value NOT in array

后端 未结 5 939
渐次进展
渐次进展 2021-01-20 07:56

How would I select a random value (0 to 30) that is not in this array?

var list = new Array(1,3,4,7,8,9);
5条回答
  •  北荒
    北荒 (楼主)
    2021-01-20 08:11

    Assuming your list is reasonable small in size, create a list of numbers that are not in the array and then select a number from that array at random.

提交回复
热议问题