elmid = "R125";
switch(true){
case elmid.match(/R125/):
idType = "reply";
break;
}
alert(idType); // Returns undefined
-------------------BUT----------------------
elmid = "R125";
if (elmid.match(/R125/)){idType = "reply";}
alert(idType); // Returns "reply"
Using the swtich returns undefined but using an if returns the expected value, what is causeing the switch to fail ? Why is this the case? what am i doing wrong here? can any one explain why I get different results =).
NOTE: No advices to use an if statement in this case I know that, my question concise for asking there hence there is not only 1 case in the switch statement.