JS outputs random numbers within a specified range

/* Custom function */ 
function GetRandomNum(Min,Max){
     var Range = Max - Min;
     var Rand = Math.random();
     return (Min + Math.round(Rand * Range));
}

/* call function */ 
var num = GetRandomNum(4,10);

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325205276&siteId=291194637