Looking at the following Switch statement, if my value is 3 (I have made sure the type of value is a number by using parseInt(value, 10) so that's not the problem - also console.log(typeof value) would result in 'number') the 'name' variable should be set to 'three'. it's not the case though, and the switch statement directly goes to default. to make sure that the logic is correct, I changed the value to '1' and the 'name' variable got set to 'one'. why doesn't this work for value '3'? It's blown my mind!
switch (value) {
case 0:
name = "zero";
break;
case (value & 1 == 1):
name = "one";
break;
case (value & 2 == 2):
name = "two";
break;
case (value & 3 == 3):
name = "three";
break;
default:
break;
}
any ideas?