DEV Community

Discussion on: Our favorite javascript one-liners

Collapse
 
lionelrowe profile image
lionel-rowe

Math.floor(Math.random() * 0xffffff) gives numbers in the range 0..0xfffffe, not 0..0xffffff. You want Math.floor(Math.random() * (0xffffff + 1)), i.e. Math.floor(Math.random() * 0x1000000) 😉

Collapse
 
stackcache profile image
J. Everly Health

this guy hexes...

Some comments have been hidden by the post's author - find out more