Skip to content

Instantly share code, notes, and snippets.

@akashsky44
Last active October 17, 2018 11:03
Show Gist options
  • Save akashsky44/0a31defd91c7ba8c10a0af8c6c18aa8b to your computer and use it in GitHub Desktop.
Save akashsky44/0a31defd91c7ba8c10a0af8c6c18aa8b to your computer and use it in GitHub Desktop.
JavaScript Random String Value
function randomString() {
var chars = "0123456789";
var string_length = 7;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
}
return randomstring;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment