title: What is wrong with the logic of my character changing function?
body: <p>I've tried to create a character changing function for strings, it suppose to change all the "-" to "_", and it only does it for the first character and leaves the rest. If someone could explain it would be grate.</p>
  
  <pre><code>function kebabToSnake(str) {
      var idNum = str.length;
      for(var i = 0; i &lt;= idNum; i++) {
          var nStr = str.replace("-", "_");
      }
      return nStr;
  }
  </code></pre>