Hi I found this piece of JS code which generates zero or one: I don't understand how the pipe (ORing) is involved here?
var randomNum = ((Math.random () * 2 | 0) + 1) - 1; // random number between 0 and 1
I found another way
Math.floor(Math.random()*2)
which accomplishes the same goal. Which one is preferred?