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 ランダム 整数 覚書

Last updated at Posted at 2019-04-24

###0~1未満のランダム値

Math.random() 

###小数点以下切り捨て

Math.floor

##ランダムな整数値

// 0,1,2 のランダムな整数値
Math.floor(Math.random() * 3)

// 0.....n のランダムな整数値
Math.floor(Math.random()*(n + 1))

// min.....max のランダムな整数値
min + Math.floor(Math.random()*(max + 1 - min ))
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?