ca_redwards
01-03-2003, 03:20 AM
Let us revisit Beetle's Code Challenge! (http://www.codingforums.com/showthread.php?threadid=12285&goto=newpost) with a new twist:
Implement the string reversing function in as few characters as possible! (And use all the semicolons you like...)
Use this declaration:
function convert(t){ /*your most compact code here!*/ }
Assume that the t parameter is a textfield element thusly...
<html>
<head>
<title>Contest</title>
<script type="text/javascript">
function convert( inputObject )
{
var stringIn = inputObject.value;
var stringOut = "";
for ( var i = stringIn.length; i >= 0; i-- )
{
stringOut += stringIn.charAt(i);
}
inputObject.value = stringOut;
}
</script>
</head>
<body>
<form>
<input type="text" name="text1" size="80" />
<br />
<input type="button" value="convert" onclick="convert( this.form.text1 );" />
</form>
</body>
</html>
On your mark, get set, code!
Implement the string reversing function in as few characters as possible! (And use all the semicolons you like...)
Use this declaration:
function convert(t){ /*your most compact code here!*/ }
Assume that the t parameter is a textfield element thusly...
<html>
<head>
<title>Contest</title>
<script type="text/javascript">
function convert( inputObject )
{
var stringIn = inputObject.value;
var stringOut = "";
for ( var i = stringIn.length; i >= 0; i-- )
{
stringOut += stringIn.charAt(i);
}
inputObject.value = stringOut;
}
</script>
</head>
<body>
<form>
<input type="text" name="text1" size="80" />
<br />
<input type="button" value="convert" onclick="convert( this.form.text1 );" />
</form>
</body>
</html>
On your mark, get set, code!