I want a 5 character string composed of characters picked randomly from the set [a-zA-Z0-9].
[a-zA-Z0-9]
What\'s the best way to do this with JavaScript?
Assuming you use underscorejs it's possible to elegantly generate random string in just two lines:
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var random = _.sample(possible, 5).join('');