I don't think the switch statement is what you need here. This is one place where you should use if...else if...else if. As well, what happens if the values are exactly 1 or 2 or some other integer?
if (a>0 && a<=1)
{
....
}
else if (a > 1 && a<=2)
{
.............
}
//etc.
This is what I tried and for some reason the switch will not execute. I have but the same range logic in IF/ElseIf statements and it works. I am very confused.
Maybe you're right. All the examples I ever saw use only string values for switch labels.
There is no anything about some limitations in Netscape JS guide though.
I don't like it so much and usually use "if ... else if".
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.