0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScript ランダムに文字を表示させる(乱数)

Posted at

JSでランダムに文字や数字を表示させるには

Math.floor(Math.random() * ○○○.length

を使います。

qiita.js
const omikuji = ["大吉","小吉","",""];
const rnd = Math.floor(Math.random() * omikuji.length);

上記を実行するとランダムに、 大吉 小吉 吉 凶 と表示されます。

色々応用効きそうです。

ちなみに、JSの実行コードは

console.log(○○○);

です。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?