That's better (also cleaner and faster). I just don't trust IEEE floats :) -Josh
On Wed, Jan 7, 2009 at 4:05 AM, Manish Jethani <manish.jeth...@gmail.com>wrote: > On Tue, Jan 6, 2009 at 7:42 AM, Josh McDonald <dzn...@gmail.com> 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 > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > > > -- "Therefore, send not to know For whom the bell tolls. It tolls for thee." Like the cut of my jib? Check out my Flex blog! :: Josh 'G-Funk' McDonald :: 0437 221 380 :: j...@gfunk007.com :: http://flex.joshmcdonald.info/ :: http://twitter.com/sophistifunk