I played with this, and managed to occassionally get numbers less than 5 digits. I'd probably take the approach of getting 6 (I thought the #218 said 7) random digits individual, and string them together.

Also, Math.random() isn't considered strong random, and so could be predictable...