/Value
* lowerValue 最小值
* upperValue 最大值
*/
function select(function select(function. , upperValue){
//取值範圍總數
var choices = upperValue - lowerValue 1;
return Math.floor(Math.random() * choices lowerValue); var num = selectFrom(2, 10);
alert(num);//介於2和10之間(包括2和10)的一個數值
var colors = ["red ","green","blue","yellow","black","brown"];
var color = colors[selectFrom(0, colors.length-1)];
alert(color) ;//可能是數組中包含的任何一個值