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 5 years have passed since last update.

JavaScriptランダム乱数

Posted at

Math.randomとは?

Math.randomは0から1の間のランダムな数字をリターンするJSの関数です。

Math.randomの使い方

Math.random();

Math.randomの例

document.write("Math.random() : " + Math.random());
結果:Math.random() : 0.3482240167419748

Math.randomの例2

1から5の間の値がランダムに表示されるコード
document.write("結果:" + Math.ceil(Math.random() * 5));
結果:2

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?