This is confusing me as to why a variable is declared undefined but when I hard code it it is fine.
var lamination = ;
var price;
lamination[“500”] = 60;lamination[“1000”] = 80;lamination[“2000”] = 100;lamination[“3000”] = 150;lamination[“4000”] = 200;
switch(qty){
case ((qty)<=500): price=lamination[500];break;
case qty>500 && qty<=1000:price=lamination[1000];break;
case qty>1000 && qty<=2000:price=lamination[2000];break;
case qty>2000 && qty<=3000:price=lamination[3000];break;
case qty>3000 && qty<=4000:price=lamination[4000];break;
}
alert(price);
Cases can be comparisons as it works fine in a php environment. And also putting hard code in to each case environment will produce the correct result but passing as a variable it still declares as undeifned.
Basically the case element works but assigning it to a variable declares undefined as a result.
Also don’t really want it to run through a loop as there is more going on than just this caclulation and multiple loops in the code will slow the overall calculator down.