How do you generate a random integer number in range from 1 to 10 in JavaScript?
Math.random() method returs number in range 0 (inclusive) and 1 (exclusive). Math.floor() method rounds a number downward to its nearest integer Example:

var randomNumber = Math.floor(Math.random()*11);
where 11 dictates that the random number will fall between 0-10.

@iliana000, fixed! Thanks a lot ;)

2016 Jan 20, 6:00:10 PM

and "randoM"

2016 Jan 15, 6:31:57 AM

When will you check this mistake? It isn't told in the aswer, that the result should be INTEGER. Do you ever read comments? (on

2016 Jan 15, 6:31:33 AM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback