11 lines
285 B
TypeScript
11 lines
285 B
TypeScript
function random(length = 10) {
|
|
let text = '';
|
|
const possible = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
|
for (let i = 0; i < length; i += 1) {
|
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
}
|
|
return text;
|
|
}
|
|
|
|
export default random;
|