title: Replacing first and last characters in string (javascript)
body: <p>I need to replace first and last character in random string. Why this code doesn't work?</p>
  
  <pre><code>function symbExchange(line) {  
      var tmp = line[0];  
      var str = line.replace(line[0], line[line.length-1]);  
      var str2 = str.replace(str[str.length-1], tmp);  
      return str2;
  }
  </code></pre>