For some reason the following code doesn\'t work.
var a1 = Math.floor(Math.random()*4+1);
//Answer2
for(a2 = 0; a2 != a1 && a2 != 0; a2 = Math.floo
You are choosing a new a2 value when a2 is not the same as a1 or zero. This is backwards - you set a2 to zero before the loop, so it never executes.
You need to loop while a2 is either zero, or equal to a1:
var a1 = Math.floor(Math.random()*4+1);
//Answer2
for(a2 = 0; a2 == a1 || a2 == 0; a2 = Math.floor(Math.random()*4+1)){
// nothing here
}
alert(a2);