random


The random function is a utility function used to generate a random integer within a specified range.

Parameters

  • min: number - The lower bound of the range, inclusive.
  • max: number - The upper bound of the range, exclusive.

Returns

  • number - A randomly generated integer between min (inclusive) and max (exclusive).

Usage

import { random } from 'reactchemy'

export default function Component() {
const [two] = random()

return <div>Hello {two}</div>
}

Util

export const random = (min: number, max: number): number => Math.floor(Math.random() * (max - min)) + min