randomInt(): Random Integer Selection
randomInt() generates a pseudo-random integer in its requested bounds. It suits dice-like simulations, selecting an index, and discrete test cases.
Bound conventions
Check whether your intended endpoints are included and test boundary cases. Bounds should be integer values; use floor() or ceil() deliberately if raw limits originate from decimal calculations. Do not use round() on random() as a substitute, because it can bias endpoint probabilities.
For selecting from a collection, ensure the result matches valid indices and confirm length using size(). Reproducibility still matters for tests and simulations.