What is the correct way to generate exact value from 0 to 999999 randomly since 1000000 is not a power of 2?
0
999999
1000000
This is my approa
Here's a simple piece of code that uses the randomBytes() function.
randomBytes()
require('crypto').randomBytes(2, (err: Error, buf: Buffer) => console.log(Number.parseInt(buf.toString('hex'), 16)));