Skip to Content
๐ŸŽฒ Welcome to RandBox - Powerful JavaScript Random Data Generation Library! Learn More

function

Instead of providing a seed, which will be used to seed our Mersenne Twisterย , you can also specify an arbitrary function to generate random numbers which the rest of the library will utilize when generating everything else.

A rather simple example, simply using Math.random() instead of our Mersenne Twister

// Use Math.random() instead of our Mersenne Twister var randBox = new RandBox(Math.random); randBox.address() => '131 Asmun Pike' randBox.address() => '261 Pawnaf Highway'

RandBox will appear to work just the same, but have a different underlying random generator.

This function should return any number between 0 and 1.

Last updated on: