topical media & game development
basic-javascript-04-ch4-examp5.htm / htm
<html>
<body>
<script language="JavaScript" type="text/javascript">
var myShopping = new Array("Eggs","Milk","Potatoes","Cereal","Banana");
var ord = prompt("Enter 1 for alphabetical order, and -1 for reverse order", 1);
if (ord == 1)
{
myShopping.sort();
document.write(myShopping.join("<br>"));
}
else if (ord == -1)
{
myShopping.sort();
myShopping.reverse();
document.write(myShopping.join("<br>"));
}
else
{
document.write("That is not a valid input");
}
</script>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.