473,497 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with javascript to end a while loop by a letter

4 New Member
How do I get the program to end entering "q". Here's what I've done so far:

Expand|Select|Wrap|Line Numbers
  1. <script type = "text/javascript">
  2.  
  3. function assignFirstClass( first )
  4. {
  5.     alert ( "You are assigned seat " +  + " in first class" )
  6. }
  7.  
  8. function assignCoach ( coach )
  9. {
  10.     alert ( "You are assigned seat " +  + " in first class" )
  11. }
  12.  
  13. </script>
  14. </head>
  15. <body>
  16.  
  17. <script type = "text/javascript">
  18.  
  19. var firstclass = new Array ( 5 );
  20. var coachclass = new Array ( 5 );
  21. var question = "y";
  22.  
  23. while ( question.toLowerCase() == "y" )
  24. {
  25.     question = prompt ( "Please Type\n'F' For First Class Ticket\n'C' For Coach Seating\n'V' For View Seating Chart\n'Q' For Quit Program" )
  26.  
  27.  
  28.     if ( question.toLowerCase() == "f" )
  29.         firstclass [ i ] = 1
  30.         assignFirstClass ( firstclass )
  31.  
  32.  
  33.     if ( question.toLowerCase() == "c" )
  34.         coachclass [ i ] = 1
  35.         assignCoach ( coachclass )
  36.  
  37.     if ( question.toLowerCase() == "v" )
  38.         alert ( firstclass + coachclass )
  39.  
  40.     question = prompt( "Please Type\n'F' For First Class Ticket\n'C' For Coach Seating\n'V' For View Seating Chart\n'Q' For Quit Program" );
  41. }
  42. </script>
  43.  
May 16 '10 #1
3 1277
acoder
16,027 Recognized Expert Moderator MVP
There's a lot of tasks there. This looks like homework, so I'll take this opportunity to remind you of the site guidelines on homework and coursework.

We can help you on a particular question that you may have.
May 16 '10 #2
Beeb
4 New Member
my thread is updated
May 16 '10 #3
acoder
16,027 Recognized Expert Moderator MVP
Change == "y" to != "q".
May 17 '10 #4

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

Similar topics

5
3440
by: Dariusz | last post by:
I want to use arrays in my website (flat file for a guestbook), but despite having read through countless online tutorials on the topic, I just can't get my code to work. I know there are...
1
3321
by: Matt | last post by:
My problem is when the user click the submit button, it will launch another new window for the request page. I want to confirm we cannot use JavaScript open window functions to open a request page?...
8
7696
by: Lucy | last post by:
help! javascript inline of an HTML to open an HTML in a target window. Something like... <html> <head> <title>test</title> </head> <body>
41
4873
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
1
2365
by: rapin | last post by:
How do you make javascript’s string functions (like toUpperCase() or substr()) run under SpiderMonkey to handle multi-byte characters. For example: var strTest = "ørnen på"; var ...
2
1184
knychtell
by: knychtell | last post by:
Good day to you, im a junior here, i wonder if someone could help me about arrays.... i just need a brief instruction of what an array is and its uses, i already have several books but it dont say...
4
2488
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
5
8059
by: howa | last post by:
Hi, Consider a simple example, e.g. var a = { 'a': 'b', 'c': 'd' }
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7160
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,...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5456
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,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1405
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.