gobbly2100
Dec 11th 2007, 3:40 pm
Hey, I don't understand how the switch statement works, I think I am doing everything right but am obviously missing something because I just can't get the damn thing to work.
Here is what I have so far:
var state = prompt("What state are you in?", "");
switch(state.toUppercase()) {
case "CA" :
alert("You live in CA");
break;
case "HI" :
alert("You live in HI");
break;
default :
alert("Heck know's where you live");
break;
}
It just alerts me the default text even if I type in one of those states.
Any help is much appreciated.
Thanks!
Here is what I have so far:
var state = prompt("What state are you in?", "");
switch(state.toUppercase()) {
case "CA" :
alert("You live in CA");
break;
case "HI" :
alert("You live in HI");
break;
default :
alert("Heck know's where you live");
break;
}
It just alerts me the default text even if I type in one of those states.
Any help is much appreciated.
Thanks!