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

set

// usage randBox.set(key, value)

Used for overriding the default data used by randBox.

For example, if instead of the default set of last names (which were pulled from the U.S. census data and therefore obviously American biased), you could replace the data for the first names with something more suited to your task. For example, if you want instead to pick from last names of houses in A Song of Ice and Fire, you could do something like:

randBox.set('lastNames', ['Arryn', 'Baratheon', 'Bolton', 'Frey', 'Greyjoy', 'Lannister', 'Martell', 'Stark', 'Targaryen', 'Tully', 'Tyrell']); // then randBox.last() => 'Lannister'

This is very handy for internationalization.

Available keys for datasets to override: firstNames, lastNames, provinces, us_states_and_dc, territories, armed_forces, street_suffixes, months, cc_types, currency_types

Last updated on: