Math.floor(Math.random() * 11); 0-10,
why *11 ?
Explanation: Math.random() will generate number between 0-1 (Excluding the 0 and 1) so between 0.00000001 to 0.999999 floating-point, so let say the number generated randomly is 0.99999, times that by 10 = 9.9999 right ? then the Math.floor, will bring that down to 9, removing all those decimal points, so the highest possible answer now is 0-9, but if you multiply the random number to 11, example again, the random generated number is 0.99999 x 11 = 10.99989, then Math.floor(10.99989) will down and remove all the decimal numbers so math.floor(10.99989) = 10, that is why it is
Math.floor(Math.random() * 11); and not *10.
Question and answer is powered by AnsPress.io