_"added 1 to left 10" no, you scale the random value over the range of possible output values.
You want a result in the range 10 - 20 inclusive, which is 11 possible integer values so you multiply the random value, x, (0 <= x < 1) by 11 to get a value, n, such that, 0 <= n < 11. By flooring the result you get an integer between 0 and 10 (inclusive). You then add 10 to this to get a value in the range 0 - 20.
Following that same logic for your second example Math.floor(Math.random() * 8) + 2;
Math.random() * 8
- results in a number x where 0 <= x < 8.
Math.floor(x)
- gives an integer between 0 and 7, inclusive.
+ 2
- add an offset so the result is in the range 2 - 9.
To get a number between 2 and 8, you should change the initial 8
to 7
as you want a number in the range 2 - 8, which is one of 7 distinct integer values.
You shouldn't just add 1 without understanding the algorithm first. Once you do you can get a random integer between any 2 arbitrary numbers.