2 ms·
I don't know what's up with his sample JS, a simple "Math.floor(Math.random() * 9999)" would be better.
by Jyaif 9y ago
I don't know what's up with his sample JS, a simple
"Math.floor(Math.random() * 9999)" would be better.
- blahedo 9y agoI wondered the same thing, but this guarantees not starting with a 0, which I could imagine breaking some people's idea of what a passcode should look like.
- deleted 9y ago[deleted]
- wakamoleguy 9y agoMy only guess is that they assume people will be confused by 3-digit (or fewer) results. They could have coerced it to a string, though, which yields pretty good results: (Math.floor(Math.random() * 10000) + 10000 + "").substr(1)