random positive negative numbers javascript code example Example: math random from minus 1 var plusOrMinus = Math.random() < 0.5 ? -1 : 1;