Link Search Menu Expand Document

Random

Table of contents

  1. Random
    1. Random.random() -> Number
    2. Random.range(Number: lowest, Number: highest) -> Number
    3. Random.select(List) -> value

Random

To make use of the Random module an import is required.

Note: This is not cryptographically secure and should not be used for such purposes.

import Random;

Random.random() -> Number

Return a random decimal between 0 and 1.

Random.random(); // 0.314
Random.random(); // 0.271

Random.range(Number: lowest, Number: highest) -> Number

Returns a random integer between the lowest and highest inputs where both are inclusive.

Random.range(1, 5); // 2
Random.range(1, 5); // 4
Random.range(0, 2); // 1

Random.select(List) -> value

Returns a value randomly selected from the list.

Random.select([2, 4, 6]);  // 6
Random.select([2, 4, 6]);  // 2
Random.select(["a", "b", "c"]); // "c"

This site uses Just The Docs, with modifications.