randomInt - Generate a pseudorandom integer
randomInt
will create a pseudorandom number between 0
and n
exclusively.
Note
randomInt
is not a cryptographically secure source of randomness.
Syntax
Like many functions in DataPrime, randomInt
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
upperBound | number | true | The highest value the random number can be, exclusively. |
Example - Basic usage
To create a random number from 0 to 99 and add it as a field named random_num
to a document, one can simple combine randomInt
with the create
command:
Theme
Light