Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function random(min,max){
- if(max == null || max == undefined){
- max = min;
- min = 0;
- }
- min = min || 0;
- max = max || 4000000;
- if(min >= max){
- min = max + 1;
- }
- while(true){
- var val = _random(max);
- if(min >= val)
- continue;
- return val;
- }
- }
- function _random(max){
- if(!max || max <= 0)
- max = 101;
- var num = Math.floor(Math.random()* max);
- if(num === 0)
- num = 1;
- return num;
- }
Advertisement
Add Comment
Please, Sign In to add comment