Last active
October 17, 2018 11:03
-
-
Save akashsky44/0a31defd91c7ba8c10a0af8c6c18aa8b to your computer and use it in GitHub Desktop.
JavaScript Random String Value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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