Please send questions to
st10@humboldt.edu .
<html>
<!--
js_arr1.html
adapted by: Sharon Tuttle
last modified: 09-07-06
-->
<head>
<title> js_arr1 </title>
</head>
<body>
<h3> js_arr1.html </h3>
<h4> (by Sharon Tuttle, last modified 09-07-06) </h4>
<hr>
<script type="text/javascript">
<!--
var howMany = prompt("How many items will you enter?")
if ( isNaN( Number(howMany) ) )
{
document.write("<h2> NO elements --- we're done </h2>")
}
else // try to read in that many into an array
{
howMany = Number(howMany)
var items = new Array(howMany)
for (var i=0; i < items.length; i++)
{
nextItem = prompt("Enter the next item: ")
items[i] = nextItem
}
items.sort()
// now display items in a sorted, unnumbered list
document.write("<h2> Those elements sorted lexicographically:",
" </h2>")
document.write("<ul>")
for (i in items)
{
document.write("<li> " + i + ": " + items[i] + " </li>")
}
document.write("</ul>")
}
//-->
</script>
<noscript>
<hr>
<h3> Your browser does not support JavaScript, or has it disabled;
<br>
please note that, as a result, this page will not work. </h3>
<hr>
</noscript>
<hr>
</body>
</html>