Enable functions after answering the first question

  Below is the HTML and Javascript source code for this page.                           
                                                                   
  It is rudimentary programming.
  
  Please find the four quiz questions and answer them as quickly   
  as you can.                                                      




<button onclick="display.innerHTML= data= new Array(4,6,2,7,3,1,5)">reset</button><br>
<button onclick="display.innerHTML= x1(data)">function x1</button><br>
<button onclick="display.innerHTML= x2(data)">function x2</button><br>
<div id="output"></div>


<script type="text/javascript">

var data= new Array(4,6,2,7,3,1,5);
var display= document.getElementById('output');
display.innerHTML= data;


/* ******************************************************************
 *                                                                  *
 * 1) Both functions attempt tp accomplish the same thing.  What    *
 *    is it?                                                        *
 *                                                                  *
 * 2) Both functions have an error, one of which will freeze some   * 
 *    browsers.  Find the; Debug them.                              *
 *                                                                  *
 * 3) Ragardless of size, which function is written more            * 
 *    elegantly?  Why?                                              *
 *                                                                  *
 ********************************************************************/



// ===============================================================
function x1( n ){
	var notdone= true;
	while ( notdone ){
		notdone= false;
		for ( i= 0; i < n.length; i++ ){
			if ( n[i] < n[i-1] ){
				var t= n[i];
				n[i]= n[i-1];
				n[i-1]= t;
				notdone= true	
			}			
		}	
	} 
	return n
}



// ===============================================================
function x2( n ){
	var notdone= true;
	while ( notdone ){
		var i= 0;
		while ( ++i < n.length ){
			if ( n[i] < n[i-1] ){ var t= n[i]; n[i]= n[i-1]; n[i-1]= t }
		}		
		var i= 1;
		while ( i < n.length && n[i-1] <= n[i++] ){}
		if ( i < n.length ){ notdone= false }
	}		
	return n
}






/* ******************************************************************
 *                                                                  *
 * 4) Write code that swaps the integer values of two variables     *
 * without using a third temporary variable.                        *
 *                                                                  *
 * e.g.                                                             *
 *  int A = 4                                                       *
 *  int B = 7                                                       *
 *  Cause A to contain the value stored in B and B to contain       *
 *  the value stored in A without temporarily storing one of the    *
 *  values in a third varaible.                                     *
 *                                                                  *
 ********************************************************************/
</script>