Possible Duplicate:
Generate random between 0 – 9 but not 6
var ifanse=Math.floor(Math.random()*4)+1;
var ifanse2=Math.floor(Math.random()*3)+1
These are 2 random numbers. Sometimes they come equal, but is there any way if ifanse come equal to ifanse2, it will regenerate a random between 3 – 1 but exclusive of ifanse2. Or is there any way to avoid equaling at first place?
You could loop until you pick a different number: