Created
April 18, 2017 09:46
-
-
Save nyawach/431ce02558530e1c5be7088a26df642a to your computer and use it in GitHub Desktop.
[a-zA-Z0-9]のランダムな文字列を出力する
This file contains hidden or 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
getRandomString(length = 8) { | |
// 生成する文字列に含める文字セット | |
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | |
let r = ""; | |
for(let i = 0, charsLength = chars.length; i < charsLength; i++){ | |
r += chars[Math.floor(Math.random()*cl)]; | |
} | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment