It looks like
Math.random()*6 +1|0 works the same as
Math.floor(Math.random()*6 + 1
but I do not understand how 1|0 works.:confused:
Printable View
It looks like
Math.random()*6 +1|0 works the same as
Math.floor(Math.random()*6 + 1
but I do not understand how 1|0 works.:confused:
It is clearer when writtenA bitwise OR operation converts the result to an integer, removing the decimal fraction.Code:( Math.random() * 6 + 1 ) | 0 ;
Thanks! That's cool!