DEV Community

Discussion on: Random Number Generation in JS

nastyox1 profile image

Very cool approach! I noticed that you disallowed leading zeros, and I think that's a good choice because the function returns a number, not a string, and leading zeros would be ignored anyway. The only time I think a zero might be expected as the first digit would be when calling getRandom(1). You might expect 0 to be a possible result then, but it's not currently.

Love the function; very creative.