aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.ts
blob: 0dc0bb144b6202a2a9168b02179db892d92d6ee4 (plain) (blame)
1
2
3
4
5
6
7
8
9
/**
 * Returns a random number between min (inclusive) and max (exclusive)
 */
export function getRandomInt(min: number, max: number): number {
  return Math.floor(Math.random() * (max - min) + min);
}
export function getRandomEl<T>(arr: Array<T>): T {
  return arr[getRandomInt(0, arr.length)];
}