+ 2

I need to know how to make a random number (in a range of 0-9)

25th Jun 2017, 9:57 PM
benjamin leib
benjamin leib - avatar
4 Answers
+ 2
function randomIntFromInterval(min,max) { return Math.floor(Math.random()*(max-min+1)+min); } var random = randomIntFromInterval(0,9); in the place of min and max with this function you can have any number between two numbers randomly. in my example is from 0 till 9
25th Jun 2017, 10:19 PM
Mantvydas BĆ«da
Mantvydas BĆ«da - avatar
+ 2
Try this randomNum = ~~(Math.random()*10);
26th Jun 2017, 1:27 AM
CalviŐČ
CalviŐČ - avatar
0
import random random_number = random. randint(0,9) print(random_number)
25th Jun 2017, 10:30 PM
Mohammed Chami
Mohammed Chami - avatar