JS-Rando Examples in React

npm install js-rando

import Rando from 'js-rando';

const rando = new Rando()

Random value between 0 & 1

Method:

rando.Random()

Output:

0.7253388180797179

Random Integer between 1 & 10

Method:

rando.RandomInt(1, 11)

Output:

5

Random Float between 10 & 20 with 3 significant digits

Method:

rando.RandomFloat(10, 21, 3)

Output:

16.682

Random Array Element

Method:

rando.RandomElement(["dog", "cat", "fish", "bear"])

Output:

fish

Random Hex Digit

Method:

rando.RandomHex()

Output:

6

Random Hex Color

Method:

rando.RandomHexColor()

Output:

Random Hex Color

Use in React:

<div style={{backgroundColor: rando.RandomHexColor()}}></div>

Random RBG Color

Method:

rando.RandomRBG()

Output:

rgb(229, 15, 114)

Use in React:

<div style={{backgroundColor: rando.RandomRGBColor()}}></div>

Random RBGA Color

Method:

rando.RandomRBGA()

Output:

rgba(156, 53, 67, 1)

Use in React:

<div style={{backgroundColor: rando.RandomRGBAColor()}}></div>