I am trying to write a couple of statements that chooses either 0 or 1
and I want 0 and 1 to have the equal possibilities
I did this
chosendirection = Math.floor(Math.random()*2);
but the above does not choose 0. It chooses 1 only.
Thanks!
I am trying to write a couple of statements that chooses either 0 or 1
and I want 0 and 1 to have the equal possibilities
I did this
chosendirection = Math.floor(Math.random()*2);
but the above does not choose 0. It chooses 1 only.
Thanks!
Math.round(Math.random())
Math.random already returns a value between 0 and 1