Last active
February 2, 2019 02:11
-
-
Save sean-clayton/d59f30441d967bead84a3efc21ff0b98 to your computer and use it in GitHub Desktop.
Create a random n-digit string in JS.
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 randomDigitString(n) { | |
var x = n; | |
if (typeof n !== "number") x = 1; | |
if (n < 1) x = 1; | |
if (n > 19) x = 19; | |
return Math.random().toString().substr(2, x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment