+ 2

Random Numbers in JavaScript

What is the best way to get specific random numbers?

27th Jan 2018, 12:41 AM
Yahir
Yahir - avatar
7 odpowiedzi
+ 7
Random number between 0.0 and 1.0: Math.random() Random number between 1 and n: Math.floor(Math.random() * n) + 1 Random number between min and max: Math.floor(Math.random() * (max - min + 1) + min)
27th Jan 2018, 12:55 AM
SplittyDev
SplittyDev - avatar
+ 2
JavaScript
27th Jan 2018, 12:51 AM
Yahir
Yahir - avatar
+ 2
Well, you could try the Math.random method. If that helps
28th Jan 2018, 3:17 AM
Castlebreaker
Castlebreaker - avatar
+ 1
In what language?
27th Jan 2018, 12:51 AM
SplittyDev
SplittyDev - avatar
0
I’m trying to get random numbers in between 1 and 3 with no decimals
27th Jan 2018, 2:06 AM
Yahir
Yahir - avatar
0
Thanks
27th Jan 2018, 3:16 AM
Yahir
Yahir - avatar
0
I already know that method
28th Jan 2018, 4:43 PM
Yahir
Yahir - avatar