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

character

// usages randBox.character() randBox.character({ pool: 'abcde' }) randBox.character({ alpha: true }) randBox.character({ numeric: true }) randBox.character({ casing: 'lower' }) randBox.character({ symbols: true })

Return a random character.

randBox.character(); => 'v'

By default it will return a string with random character from the following pool.

'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()'

Optionally specify a pool and the character will be generated with characters only from that pool.

randBox.character({ pool: 'abcde' }); => 'c'

Optionally specify alpha for an alphabetic character.

randBox.character({ alpha: true }); => 'N'

Optionally specify numeric for a numeric character.

randBox.character({ numeric: true }); => '8'

Default includes both upper and lower case. Itโ€™s possible to specify one or the other.

randBox.character({ casing: 'lower' }); => 'j'

Note, wanted to call this key just case but unfortunately thatโ€™s a reserved word in JavaScript for use in a switch statement

Optionally return only symbols

randBox.character({ symbols: true }); => '%'
Last updated on: