Simple JavaScript encryption function
<p>I have a function which has to change characters from one array to the characters from another. It is kind of simple encryption. I have:</p>

<pre><code>var plainArray = ['A','B','C',...,'Z'];
var cipherArray = ['a','b','c',...,'z'];
function rotateToPosition(signalCharacter, indexCharacter, plainAlphabet, cipherAlphabet)
</code></pre>

<p>already working. 
Now I have to write a function which will change given word into encrypted word. </p>

<pre><code>function encrypt(plainText, signalCharacter, indexCharacter, plainAlphabet, cipherAlphabet)
{
   var encryptedString = signalCharacter;
   //i is what will hold the results of the encrpytion until it can be appended to encryptedString
   var i;
   // rotate array to signal character position
   var rotateArray = rotateToPosition(signalCharacter, indexCharacter, plainAlphabet, cipherAlphabet);
   for (var count = 0; count &lt; plainText.length; count++)
   {
       plainAlphabet = plainText.charAt(count);
       i = cipherAlphabet[plainAlphabet];
       encryptedString = encryptedString + rotateArray[i];
   }

   return encryptedString;
}
</code></pre>

<p>This function returns signal character and then a string of errors. Do you know what is wrong?</p>
