Random number between negative and positive value
javascript, numbers, random
Solution
var num = Math.floor(Math.random()*99) + 1; // this will get a number between 1 and 99;
num *= Math.round(Math.random()) ? 1 : -1; // this will add minus sign in 50% of cases
Altogether
var ranNum = Math.ceil(Math.random() * 99) * (Math.round(Math.random()) ? 1 : -1)
Problem
Possible Duplicate: Generating random numbers in Javascript in a specific range? How can i get a random value between, for example, from -99 to 99, excluding 0?