pwned
08-03-2003, 09:46 PM
i have this script written to "pig latinize" a string
<html>
<head>
<title>
E.C.
</title>
<font color = "black">
<script language="javascript">
pigPrompt = prompt("Type in sentence you want to be 'pig latinized'");
var splitArray = pigPrompt.split(" ");
for (var i = 0; i < splitArray.length; i++)
{
var words = splitArray[i];
slicer = words.slice(0, 1);
sstring = words.substring(1, words.length)
var together = sstring + slicer +"ay ";
var together2 = together2 += together;
}
document.writeln(together2);
</script>
</html>
now, everything works ok...except it sticks an "undefined" at the beginning
I dont know where this could be coming from
for example if you wrote in "hello how are you today"
it would result in
"undefinedelloHay owhay reaay ouyay odaytay"
If anyone could help me i'd be greatful, thank you.
Eric
<html>
<head>
<title>
E.C.
</title>
<font color = "black">
<script language="javascript">
pigPrompt = prompt("Type in sentence you want to be 'pig latinized'");
var splitArray = pigPrompt.split(" ");
for (var i = 0; i < splitArray.length; i++)
{
var words = splitArray[i];
slicer = words.slice(0, 1);
sstring = words.substring(1, words.length)
var together = sstring + slicer +"ay ";
var together2 = together2 += together;
}
document.writeln(together2);
</script>
</html>
now, everything works ok...except it sticks an "undefined" at the beginning
I dont know where this could be coming from
for example if you wrote in "hello how are you today"
it would result in
"undefinedelloHay owhay reaay ouyay odaytay"
If anyone could help me i'd be greatful, thank you.
Eric