title: How to remove the line break at the end of a string?
body: <p>How do I remove a line break at the end of a string? I can use RegEx or string.indexOf().</p>
  
  <p>What I have so far doesn't work: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var message = "first paragraph.\n\nNext paragraph.\n";
  var trimMessage = message.lastIndexOf("\n")==0 ? message.substring(0, message.length-2) : message;</code></pre>
  </div>
  </div>
  </p>