How to Generate n-Character Random Alphanumeric Strings in JavaScript
I’ll introduce how to generate n-character random alphanumeric strings in JavaScript.
When running JavaScript in Zapier, you cannot use crypto, so please use the following sample code.
var N = 3;
var randStr = Math.random().toString(36).slice(-N);
var S = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
var N = 3
Array.from(crypto.getRandomValues(new Uint8Array(N))).map((n)=>S[n%S.length]).join('')
The results of executing the above sample code are as follows (executed 5 times):
"RTC"
"T9E"
"85X"
"8B7"
"LR5"
That’s all from the Gemba about generating n-character random alphanumeric strings in JavaScript.