tags:

views:

28

answers:

2

I'm writing a script to take an array of strings, split them by characters, and print them out to the screen. This is what I have and for some reason it is not doing anything. Any ideas?

function autowrite() {
        var write_text=["Your Memories","Your Thoughts","Your Photos"];
        var split_text = Array();
        var i;
        var c;
        for(i=0; i < write_text.length; i++)
        {
            split_text[i] = write_text[i].split("");
            for(c=0; i < split_text.length[i]; i++)
            {
                alert(split_text[i][c]);
            }
        }
    }
+1  A: 

Your second loop is using the variable from the first loop.

You need to check and increment c, not i.

Also, the expression split_text.length[i] is wrong; you need to get the ith element of the split_text array, not of the length property.

Change it to

        for(c=0; c < split_text[i].length; c++)
SLaks
A: 
sushil bharwani