The Math.floor()
is to drop the decimal portion of the Number
. It is the opposite of Math.ceil()
.
You can also double the invert bitwise operator (~~
) to achieve the same as Math.floor()
(though of course the floor()
method is much more readable to most).
~~(Math.random() * 256)