On Oct 4, 7:06 am, Charlie <charlie...@gmail.com> wrote:
> put all the bios in  containers with same class, use javascript random() 
> function to create a random index to show one of the bios
> $('.bioClass').hide()
> var bioIndex=Math.round(Math.random()*5)

Using that formula, indices 0 and 5 have only half the chance of being
returned as indices 1 to 4, so not a very random selection. Use floor
or ceil for an even distribution, for speed use:

  var bioIndex = (Math.random()*6) | 0;

which is the same as using Math.floor. To return a random integer
between 0 and n, use:

  function getRandomInt(n) {
    return Math.random()*n | 0;
  }


--
Rob

Reply via email to