[solved] Random numbers?
Posted: Tue Jan 13, 2009 12:06 pm
I was looking at the source of a website I wrote awhile ago and I think I might have made a mistake. I'm not sure though because Javascript isn't really my strong suit.
I'm trying to generate a random number within my array's index bounds. It works, but I don't think it's actually random. Can someone explain a better way to do this to me?
Code: Select all
function genrand(maxnum) {
var randnum=Math.floor(Math.random()*maxnum);
return randnum;
}
function gennew(length) { // length is the length of an array
var currloc = genrand(length);
//...