Last active
March 18, 2021 18:07
-
-
Save deyvicode/f4d0ad2dcdfffd20e5d92d29928e141e to your computer and use it in GitHub Desktop.
generate random characters by lenght number
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 makeid(length) { | |
var result = ''; | |
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
var charactersLength = characters.length; | |
for ( var i = 0; i < length; i++ ) { | |
result += characters.charAt(Math.floor(Math.random() * charactersLength)); | |
} | |
return result; | |
} | |
console.log(makeid(5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment