Pick a random integer between 1 and 100
A teacher wants to call on one of 100 students at random. They set the range from 1 to 100 and request a single number, with duplicates allowed (irrelevant when quantity is 1).
ResultOne integer in [1, 100], each with probability 1/100 = 1%.
The browser calls crypto.getRandomValues to fill a 32-bit unsigned integer, rejects values that would bias the result (a technique called rejection sampling), then maps the remaining value into the inclusive range 1-100 using the formula min + floor(r * (max - min + 1)). Because crypto.getRandomValues is seeded from the operating system's entropy pool, the result cannot be predicted from previous draws.