replace Nth occurence in string - JavaScript
<p>I'm sure this was supposed to work, but I can't get it doing what I want it to:</p>

<pre><code>new_str = old_str.replace(3, "a");
// replace index 3 (4th character) with the letter "a"
</code></pre>

<p>So if I had <code>abcdef</code> then above should return <code>abcaef</code> but I must have gotten something wrong. It is changing characters, but not the expected ones.</p>

<p>Either native JS or jQuery solution is fine, whatever is best (I'm using jQuery on that page).</p>

<p>I've tried searching but all tutorials talk of Regex, etc. and not the index replace thing.</p>
