473,395 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

code help

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;
}

Oct 25 '06 #1
3 1034
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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Oct 25 '06 #2
That's sensible advice Randy. I'll try it and post it.
Cheers

On Oct 24, 9:50 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
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 advanceYou start by truing to write a switch/case function, test it, then post
your best effort at it.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Oct 25 '06 #3
roohbir wrote:
That's sensible advice Randy. I'll try it and post it.
Please don't top post, reply below trimmed quotes.

You might find this reference handy:

<URL:
http://developer.mozilla.org/en/docs...tements:switch
>

--
Rob

Oct 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mark Reed | last post by:
Hi all, I am trying to learn a little about programming (I know next to nothing so far) and have found some code which hides the toolbars. However, this bit of code is a little too effective and...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
19
by: Swaregirl | last post by:
Hello, I would like to build a website using ASP.NET. I would like website visitors to be able to download code that I would like to make available to them and that would be residing on my...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.