Skip to content

Instantly share code, notes, and snippets.

@semiherdogan
Last active July 21, 2020 09:06
Show Gist options
  • Save semiherdogan/89f77553f4c57c84c4f0aa15b32bbe73 to your computer and use it in GitHub Desktop.
Save semiherdogan/89f77553f4c57c84c4f0aa15b32bbe73 to your computer and use it in GitHub Desktop.
Boop random string generator
/**
{
"api":1,
"name":"Random String",
"description":"Generates random string",
"author":"Semih",
"icon":"quote",
"tags":"random, string"
}
**/
function main(state) {
state.fullText = state.fullText + '\n' + randomString(10);
state.postInfo('Random string generated');
}
function randomString(length) {
const Characters = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz123456789';
const CharactersLength = Characters.length;
let result = '';
for (let i = 0; i < length; i++) {
result += Characters.charAt(Math.floor(Math.random() * CharactersLength));
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment