bubbleSort.js
/**
* Prints the contents of an array as paragraph text
* inside a web page element (e.g. a paragraph element).
* @param {Array} an array of objects
* @param {String} the identifier for the HTML element
*/
Prints the contents of an array as paragraph text
inside a web page element .
Prints the contents of an array as paragraph text inside a web page element .
function printArray(A, outputElementID) {
	var testArea = document.getElementById(outputElementID);
	if (typeof A.length != "number") {
		testArea.innerHTML = "Error: A is not an array!";
		return;
	}
	if (typeof A[0] != "number") {
		testArea.innerHTML = "Error: A is not an array of numbers!";
		return;
	}
	var output = ("A[" + A.length + "] = { ");
	for (var i = 0; i < A.length; i++) {
		output += A[i];
		if (i < (A.length - 1)) output += ", ";
		else output += " ";
	}
	output += " }.";
	testArea.innerHTML = output;
}
function printArray ( A , outputElementID ) { var testArea = document . getElementById ( outputElementID ) ; if ( typeof A . length != "number" ) { testArea . innerHTML = "Error: A is not an array!" ; return ; } if ( typeof A [ 0 ] != "number" ) { testArea . innerHTML = "Error: A is not an array of numbers!" ; return ; } var output = ( "A[" + A . length + "] = { " ) ; for ( var i = 0 ; i < A . length ; i ++ ) { output += A [ i ] ; if ( i < ( A . length - 1 ) ) output += ", " ; else output += " " ; } output += " }." ; testArea . innerHTML = output ; }
Prints the contents of an array as paragraph text
inside a web page element (e.g.
Prints the contents of an array as paragraph text inside a web page element ( e . g .
// Create a reference to the corresponding HTML element. // Ensure that A is an array of Number values. // Create a text description of the array, A. // Display the text description of the array on the web page.