Math.random() provides a random number from [0,1) (floating point: '[' = inclusive, ')' = exclusive).
So in Math.floor( (Math.random() * 10) + 1); multiplying Math.random() by 10 will provide a random number from [0, 10).
The +1 after the multiplication will change the output to be [1, 11).
Then finally Math.floor( ... ) converts the random number that is in the range from [1, 11) to an integer value.
So the range of the executed statement will be all integers from [1, 10]. Or to be more specific it will be one of the numbers in this set: { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Videos
Math.random() provides a random number from [0,1) (floating point: '[' = inclusive, ')' = exclusive).
So in Math.floor( (Math.random() * 10) + 1); multiplying Math.random() by 10 will provide a random number from [0, 10).
The +1 after the multiplication will change the output to be [1, 11).
Then finally Math.floor( ... ) converts the random number that is in the range from [1, 11) to an integer value.
So the range of the executed statement will be all integers from [1, 10]. Or to be more specific it will be one of the numbers in this set: { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
As it is stated in MDN
The Math.random() function returns a floating-point, pseudo-random number in the range [0, 1[ that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user.
That being said the minimum value of Math.random()*10 is 0 while the upper exclusive bound is 10. Adding one to this expression result in a number in the range [1,11). Then by taking the Math.floor we take an integer number in range [0,10], since Math.floor()
returns the largest integer less than or equal to a given number.
Math.random returns a floating point number x such that:

Multiplying 10 to x yields a floating point number in the range:

And then adding 1 to 10x yields a floating point number in the range:

And finally flooring 10x + 1 yields an integer in the range:

Therefore, Math.floor(Math.random() * 10 + 1) yields an integer that lies in the range [1, 10].
Math.random generates a random number between 0 and 1. So for example it can be .124 or .42242. When you multiply this random number against something, you are basically making it so that the new result is no less than 0, but no more than the number you are multiplying it against.
So in your example, you are multiplying it against 10, which means you will get a random number between 0 and 10 with decimals; technically this range is 'more than 0, but less than 10'. The +1 just increases the total range so that it is between 1 and 11, or 'more than 1, but less than 11.
When you apply Math.floor() to this, you are rounding all of these results down. So in the case without the '+1', your finite range is actually 0-9, and with the +1 it is 1-10
The random number generator produces a value in the range of 0.0 <= n < 1.0. If you want a number between 1 and something you'll need to apply a +1 offset.
Generally you can use:
Math.floor(Math.random() * N) + M
This will generate values between M and M + N - 1.
demo Fiddle
Math.random() generates a random number between 0 and 1.
Therefore Math.random()*10 generates a random number between 0 and 10, and (Math.random()*10)+1 a number between 1 and 11.
Math.floor() drops the decimal of this number, and makes it an integer from 0 to 10.
You can see a sequential progression of the logic here
Math.random returns a floating-point number between 0 and 1.
Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range.
Multiplying this by n gives a floating point number between 0 (inclusive) and n (exclusive).
Math.floor is then used to convert this floating point number to an integer between 0 and n - 1 (inclusive).
Why would anybody call Math.floor on a Math.random result?
In a nutshell, one calls Math.floor() when you want to truncate a decimal value to its nearest integer (by just dropping the decimal portion. So, 3.9 becomes 3, 2.1 becomes 2, etc... So, you would typically use that when you need an integer and you want the integer that is smaller than or equal to the decimal value. The math library also has Math.ceil() and Math.round(). Math.ceil() gets you the next larger integer, Math.round() rounds to the nearest integer going either up or down depending upon which is closer.
I've seen it used like:
Math.floor(Math.random() * num);
Breaking Math.floor(Math.Random() * num) down into it's individual pieces and explaining each piece, you get this:
Math.random() gives you a random decimal number between 0 and 1, including 0, but not including 1. So, it might give you something like 0.38548569372.
Math.random() * num gives you a random decimal number between 0 and num, including 0, but not including num. So, if num was 10, it might give you 3.8548569372.
Math.floor(Math.random() * num)) gives you a random integer number between 0 and num, including 0, but not including num. So, it might give you 3.
Math.floor() truncates the decimal number to only the integer portion. A random integer is often used for getting a random value from an array (which needs to be an integer).
why don't we use Math.ceil() instead of using the floor() function then adding 1, wouldn't it be much easier?