I have the following code:
var t = 13;
function check() {
if ((t >= 12) && (t < 20)) {
alert(true);
}
}
Which I want to convert to switch statement. I have tried this:
function test() {
switch (t) {
case (t >= 12) && (t <= 20):
alert("> 12");
break;
}
}
But it doesn't work.I get no errors via the console.Any Ideas? Actually this question came after comparison with Pascal where i can do this:
case t of
12..19://code
end;
which is equal to
if (t>=12) and (t<=19) then
//code