Good Form for Random Number Generator?

Posted by JackCJR on Stack Overflow See other posts from Stack Overflow or by JackCJR
Published on 2012-12-14T04:57:58Z Indexed on 2012/12/14 5:03 UTC
Read the original article Hit count: 101

Filed under:
|

I wanted to get a few opinions on doing a random number generator. I read through a couple different ways to do it and this is the way that I created after doing a little reading. Is it acceptable form? Any foreseeable issues?

function master(){
function generate(){
var pickFrom= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var j = pickFrom.length;
var i = Math.floor(Math.random()*j+1); //Generates a random number
var code = pickFrom.charAt(i) //Picks a number based on what number was picked.
document.write(code)
}

x = 1;
while(x){
generate();
x--;
}
}

master();

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about random