title: Replace every nth character from a string
body: <p>I have this JavaScript:</p>
  
  <pre><code>var str = "abcdefoihewfojias".split('');
  
  for (var i = 0; i &lt; str.length; i++) {
      var xp = str[i] = "|";
  }
  alert( str.join("") );
  </code></pre>
  
  <p>I aim to replace every fourth letter in the string <code>abcdefoihewfojias</code> with <code>|</code>,  so it becomes <code>abc|efo|....etc</code>,but I do not have a clue how to do this.</p>