I need to create a random -1 or 1 to multiply an already existing number by. Issue is my current random function generates a -1, 0, or 1. What is the most efficient way of doing
Just for the fun of it:
var plusOrMinus = [-1,1][Math.random()*2|0];
or
var plusOrMinus = Math.random()*2|0 || -1;
But use what you think will be maintainable.