First of all, if you use a <select> as I showed, you avoid the problem of upper/lower case.
Secondly, a
switch( ) is by far not the most elegant way to do this. See my scheme.
But if you must use a switch and you must allow human fallible input, then you could do this:
Code:
switch ( planet )
{
case "Mercury": case "mercury": case "MERCURY":
info = "The planet closest to the sun.";
break;
case "Venus": case "venus": case "VENUS":
...
}
Do *NOT* forget the
break after each same-case-action set!
But better than that would be:
Code:
switch ( planet.toLowerCase() )
{
case case "mercury":
info = "The planet closest to the sun.";
break;
case "venus":
...
}
And, again, don't forget the
breaks.
************
EDIT: See? If I didn't write so much, I wouldn't be last to the party. <grin/>