I'm trying to create a switch statement but I can't seem to be able to use an expression that gets evaluated (rather than a set string/integer). I can easily do this with if statements but case should hopefully be faster.
I'm trying the following
function reward(amount) {
var $reward = $(#reward);
switch (amount) {
case (amount >= 7500 && amount < 10000):
$reward.text(Play Station 3);
break;
case (amount >= 10000 && amount < 15000):
$reward.text(XBOX 360);
break;
case (amount >= 15000):
$reward.text(iMac);
break;
default:
$reward.text(No reward);
break;
}
}
Am i missing something obvious or is this not possible? Google hasn't been friendly in this case.
Any help/pointers appreciated
M