Write a script that inputs a line of text, tokenizes it with String method split and outputs the tokens in reverse order.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> ReverseThem </title>

<script type="text/javascript">
<!--
function splitButtonPressed()
{
var inputString = document.getElementById( "string1" ).value;
var tokens = inputString.split( " " );
var len=tokens.length;
var reverse="";
for(i=len-1; i>=0; i--)
{
reverse= reverse +" " + tokens[i];
}
document.getElementById( "ans" ).value = reverse;
} // end function splitButtonPressed
// -->
</script>
</head>
<body>
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">&nbsp;</td>
<h1> Reverse Them</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to Reverse Input strings using Split.</p>
<form name = "ReverseThem" action = "">
<table border = "1">
<caption>Compare</caption>
<tr><td>Enter any String to Reverse</td>
<td><input name = "string1" type = "text" />
</td></tr>
<tr><td>Output String</td>
<td><textarea name="ans">
</textarea>
</td></tr>
<tr><td><input type = "button" value = "ReverseThem"
onclick = "splitButtonPressed()" /></td></tr>
</table>
</form>
</td>
</tr>
</table>

</body>
</html>