+ 1

How to make the method "Math.Random" return an integer?/Как сделать чтобы метод "Math.Random" возвращал целое число?

--

8th Jan 2018, 3:53 AM
Demid Metelnikov
Demid Metelnikov - avatar
3 odpowiedzi
+ 2
Math.floor((Math.random() * 10) + 1); That code will give you a random int between 1 and 10 If you want to start from 0 remove the + 1 If you want greater or less than 10 replace 10
8th Jan 2018, 3:59 AM
Ahmed Salem
+ 2
Thanks)
8th Jan 2018, 4:00 AM
Demid Metelnikov
Demid Metelnikov - avatar
0
Welcome :)
8th Jan 2018, 4:01 AM
Ahmed Salem