title: Replacing all instances of certain character in JS?
body: <p>I am trying to create a simple function that replaces all instances of a certain character in a string in JS. In this instance, I want to replace all <code>a</code>'s with <code>o</code>'s. </p>
  
  <p>I am pretty sure the code is right, but the output is still the original string. </p>
  
  <pre><code>function replaceLetter(string){
    for(var i = 0; i &lt; string.length; i++){
      if(string[i] == 'a'){
        console.log(string[i]);
        string[i] = 'o'
      }
    }
    return string;
  }
  
  replaceLetter('hahaha') // returns 'hahaha'
  </code></pre>
  
  <p>Why isn't it replacing a's with o's?</p>