You could do something like this:
var i = 1;
switch((i==1) + (Math.random(1)<0.3)*2) {
case 0:
//code block when neither is true
break;
case 1:
//code block when only i == 1
break;
case 2:
//code block when only random(1)<0.3
break;
case 3:
//code block when both i==1 and random(1)<0.3
break;
}
... but it is not really the nicest code, and can easily lead to mistakes when one of the tested expressions is anything else than 0 or 1 (false or true).
It is better to use if ... else
constructs to deal with this:
var i = 1;
var small = Math.random(1)<0.3;
if (i==1) {
if (small) {
//code block when both i==1 and random(1)<0.3
} else {
//code block when only i == 1
}
} else if (small) {
//code block when only random(1)<0.3
} else {
//code block when neither is true
}
+
instead of&&
– Orchitis