Help with javascript to end a while loop by a letter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Beeb
    New Member
    • May 2010
    • 4

    Help with javascript to end a while loop by a letter

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

    Code:
    <script type = "text/javascript">
    
    function assignFirstClass( first )
    {
    	alert ( "You are assigned seat " +  + " in first class" )
    }
    
    function assignCoach ( coach )
    {
    	alert ( "You are assigned seat " +  + " in first class" )
    }
    
    </script>
    </head>
    <body>
    
    <script type = "text/javascript">
    
    var firstclass = new Array ( 5 );
    var coachclass = new Array ( 5 );
    var question = "y";
    
    while ( question.toLowerCase() == "y" )
    {
    	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" )
    	
    	
    	if ( question.toLowerCase() == "f" )
    		firstclass [ i ] = 1
    		assignFirstClass ( firstclass )
    		
    	
    	if ( question.toLowerCase() == "c" )
    		coachclass [ i ] = 1
    		assignCoach ( coachclass )
    	
    	if ( question.toLowerCase() == "v" )
    		alert ( firstclass + coachclass )
    	
    	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" );
    }
    </script>
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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.

    Comment

    • Beeb
      New Member
      • May 2010
      • 4

      #3
      my thread is updated

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Change == "y" to != "q".

        Comment

        Working...