Random text string in Javascript

published Sep 28, 2015 09:40   by admin ( last modified Sep 28, 2015 09:43 )

This worked fine:

 

for(var c = ''; c.length < 32;) c += Math.random().toString(36).substr(2, 1)

 

Which reminded me of this uuid one:

"00000000-0000-4000-8000-000000000000".replace(/0/g,function(){return(0|Math.random()*16).toString(16)})