I don’t understand why my switch statement isn’t working. Could somebody help me here im perplexed.
var thisSquareFt:Number = (thisWidth*thisLength)/144
trace("square footage :" + thisSquareFt);
//Find the pricing based on square footage
switch(thisSquareFt) {
case (thisSquareFt > 0 && thisSquareFt <=5):
thisSquarePrice = 7;
break;
case (thisSquareFt > 5 && thisSquareFt <=10):
thisSquarePrice = 6;
break;
case (thisSquareFt > 10 && thisSquareFt <=15):
thisSquarePrice = 5;
break;
case (thisSquareFt > 15 && thisSquareFt <=30):
thisSquarePrice = 4;
break;
case (thisSquareFt > 30):
thisSquarePrice = 3;
break;
default :
thisSquarePrice = 999
}
So I can see from my trace that thisSquareFt is definitely a number yet none of my cases trigger. The value was NaN before I set a default. Why aren’t my conditional statements working?
Thanks