title: JavaScript Letter replacing code, not replacing capitals?
body: <p>I am trying to complete a codewars challenge as my practice coding since I will have a beginner tech test to enter a coding training program. In case you would like to know what the challenge is: <a href="https://www.codewars.com/kata/530e15517bc88ac656000716/train/javascript" rel="nofollow noreferrer">https://www.codewars.com/kata/530e15517bc88ac656000716/train/javascript</a></p>
  <p>I have written code which does what is expected. I will quote Codewars.com below:</p>
  <blockquote>
  <p>ROT13 is a simple letter substitution cipher that replaces a letter
  with the letter 13 letters after it in the alphabet. ROT13 is an
  example of the Caesar cipher.</p>
  <p>Create a function that takes a string and returns the string ciphered
  with Rot13. If there are numbers or special characters included in the
  string, they should be returned as they are. Only letters from the
  latin/english alphabet should be shifted, like in the original Rot13
  &quot;implementation&quot;.</p>
  </blockquote>
  <p>My code grabs the test string <code>&quot;grfg&quot;</code> and converts it to the word <code>&quot;test&quot;</code> which would be the equivalent to 13 letters ahead in the alphabet, however, if I pass the string as <code>&quot;Grfg&quot;</code> with the capital <code>&quot;G&quot;</code>it returns <code>&quot;gest&quot;</code> meaning that it will not replace capital letters.</p>
  <p>If I pass <code>&quot;test&quot;</code> in lower case it will return <code>&quot;grfg&quot;</code>, so it works backwards too, however, if I pass <code>&quot;Test&quot;</code> it will return <code>&quot;trfg&quot;</code> not replacing the capital again but returning the same letter.</p>
  <p>Please find the code I wrote below:</p>
  <pre><code>    function rot13(message){
        let abc = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;, &quot;g&quot;, &quot;h&quot;, &quot;i&quot;, &quot;j&quot;, &quot;k&quot;, &quot;l&quot;, &quot;m&quot;, &quot;n&quot;, &quot;o&quot;, &quot;p&quot;, &quot;q&quot;, 
   &quot;r&quot;, &quot;s&quot;, &quot;t&quot;, &quot;u&quot;, &quot;v&quot;, &quot;w&quot;, &quot;x&quot;, &quot;y&quot;, &quot;z&quot;,   &quot;a&quot;, &quot;b&quot;,  &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;, &quot;g&quot;, &quot;h&quot;, &quot;i&quot;, &quot;j&quot;, &quot;k&quot;, &quot;l&quot;, &quot;m&quot;, &quot;n&quot;, &quot;o&quot;, &quot;p&quot;, &quot;q&quot;, &quot;r&quot;, &quot;s&quot;, &quot;t&quot;, &quot;u&quot;, &quot;v&quot;, &quot;w&quot;, &quot;x&quot;, &quot;y&quot;, &quot;z&quot;];
        let msg = message.split(&quot;&quot;);
      
        for (let i = 0; i &lt; abc.length; i++){
          for (let j = 0; j &lt; abc.length; j++) {
              if (msg[j] === abc[i]) {
                
                ind = parseInt(abc.indexOf(i), 0) + 13;
                msg[j] = abc.slice(i + 13, i + 14);
                     
            };
          };
        };
        
        return msg.join(&quot;&quot;).toLowerCase();
      };
      
      rot13(&quot;test&quot;);
  </code></pre>
  <p>What is my mistake or what I should know to make sure that my code will convert the strings regardless of capitals or lowercase?</p>