By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,043 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,043 IT Pros & Developers. It's quick & easy.

Switch Statement

exoskeleton
100+
P: 104
hi dear experts...i have something to ask..does a switch statement works within a function like this:

function showstorename(str)
{

Switch (str) {
case 1:
alert ('Food')
break;

case 2:
alert ('Fashion')
break;

case 3:
alert ('Entertainment')
break;

case 4:
alert ('Hardware')
break;

default:
alert('Others')
break;

}

}
Sep 27 '06 #1
Share this Question
Share on Google+
2 Replies


10K+
P: 13,264
hi dear experts...i have something to ask..does a switch statement works within a function like this:

function showstorename(str)
{

Switch (str) {
case 1:
alert ('Food')
break;

case 2:
alert ('Fashion')
break;

case 3:
alert ('Entertainment')
break;

case 4:
alert ('Hardware')
break;

default:
alert('Others')
break;

}

}
Assuming Switch should be switch,

Your cases will never match. Default will always get executed in this case. Your switch argument should be an int or a char and your cases should be looking for that argument
Sep 27 '06 #2

exoskeleton
100+
P: 104
ah ok i see. so it should be in lower case?

Assuming Switch should be switch,

Your cases will never match. Default will always get executed in this case. Your switch argument should be an int or a char and your cases should be looking for that argument
Oct 3 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.