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.