Ok I've been asking alot of JS questions lately, and realized I just need to go learn it.
Been following tutorials at http://www.tizag.com/javascriptT very simple and straightforward.
I just want to make sure I understand this correctly. It took me a while to get it:
<script type="text/javascript">
var myString = "zero one two three four";
var mySplitResult = myString.split(" ");
for(i = 0; i < mySplitResult.length; i++){
document.write("<br /> Element " + i + " = " + mySplitResult[i]);
}
</script>
-
var myString = "zero one two three four";
Obviously that creates a simple string variable.
var mySplitResult = myString.split(" ");
That splits it using " " as the delimeter, and assigns it to the mySplitResult array. Correct? Or is it not an array?
for(i = 0; i < mySplitResult.length; i++){
Is this saying the number of values in the array? Doesn't seem like it could be saying the actual length of characters in the string.
document.write("<br /> Element " + i + " = " + mySplitResult[i]);
This just returns mySplitResult[i] variable "i". Since i is increasing with each loop, it pulls the correct information from the array.