JavaScript 产生指定范围随机数

it2022-05-05  121

function selectFrom(lowerValue, upperValue) { var choices = upperValue - lowerValue + 1; return Math.floor(Math.random() * choices + lowerValue); } var num = selectFrom(2, 10); alert(num);

 

转载于:https://www.cnblogs.com/zdfjf/p/5825307.html


最新回复(0)