On Tue, Jan 6, 2009 at 7:42 AM, Josh McDonald <[email protected]> wrote:
> A quick take on it:

Trying to improve on some already neat code...

>                 function randomLetter() : String
>                 {
>                     const noVowels : String = "BCDFGHJKLMNPQRSTVWXYZ";
>                     return noVowels.charAt(Math.round(Math.random() *
> (noVowels.length - 1)));
>                 }

  return noVowels.charAt(Math.floor(Math.random() * (noVowels.length)));

This gives a fair chance to all letters. With Math.round, B and Z were
being slightly discriminated against.

Manish

Reply via email to