Function randomIndex

Returns a random array index.

import { Arrays } from 'https://unpkg.com/ixfx/dist/data.js';

const v = [`blue`, `red`, `orange`];
Arrays.randomIndex(v); // Yields 0, 1 or 2

Use randomElement if you want a value from array, not index.

  • Type Parameters

    • V

    Parameters

    • array: ArrayLike<V>

      Array

    • rand: RandomSource = Math.random

      Random generator. Math.random by default.

    Returns number