code help

R

roohbir

I have got the following code as a nested if. How should I go about
changing it to switch? Just need some hints and I'll try to do it on my
own.
Thanks in advance

function GetShippingCost()
{
var cost = 0;
if(this.DestinationAddress=="Boston")
{
if(this.ShippingType=="Standard Delivery")
{
cost = 100
}

else(this.ShippingType=="Express Delivery")
{
cost = 200
}
}
else if(this.DestinationAddress=="Seoul")
{
if(this.ShippingType=="Standard Delivery")
{
cost = 100
}
else(this.ShippingType=="Express Delivery")
{
cost = 200
}
}
return cost;
}
 
R

Randy Webb

roohbir said the following on 10/25/2006 12:36 AM:
I have got the following code as a nested if. How should I go about
changing it to switch? Just need some hints and I'll try to do it on my
own.
Thanks in advance

You start by truing to write a switch/case function, test it, then post
your best effort at it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top