LoginSignup
0
0

More than 1 year has passed since last update.

Javascriptでランダムな文字列を生成

Posted at

https://qiita.com/fukasawah/items/db7f0405564bdc37820e
function getRandomStr(){
const LENGTH = 8 //生成したい文字列の長さ
const SOURCE = "abcdefghijklmnopqrstuvwxyz0123456789" //元になる文字
let result = ''

for(let i=0; i<LENGTH; i++){
result += SOURCE[Math.floor(Math.random() * SOURCE.length)];
}

return result //p9zh1ziw
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0