I am sorry for the very newbie question, but this is driving me mad.

I have a word. For each letter of the word, the characters position in one array is found and then returns the character at the same position found in a parallel array (basic cipher). This is what I already have: 

```
*array 1 is the array to search through*
*array 2 is the array to match the index positions*

var character
var position
var newWord 

for(var position=0; position < array1.length; position = position +1) 
{
    character = array1.charAt(count);     *finds each characters positions*
    position= array1.indexOf(character);  *index position of each character from the 1st array*
    newWord = array2[position];           *returns matching characters from 2nd array*
}

document.write(othertext + newWord);      *returns new string*

```

The problem I have is that at the moment the function only writes out the last letter of the new word. I do want to add more text to the document.write, but if I place within the for loop it will write out the new word but also the other text inbetween each word. What i actually want to do is return the othertext + newWord rather than document.write so that I can use it later on. (just using doc.write to text my code) :-)

I know its something really simple, but I cant see where I am going wrong. Any advice?
Thanks
Issy