title: Insert newline character in string javascript
body: <p>How do I insert a newline character in Javascript? The below code displays everything in one line even when using the newline character "\n".</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
    &lt;button onclick="myFunction()"&gt;Click me&lt;/button&gt;
    &lt;div id="demo" onclick="myFunction()"&gt;&lt;/div&gt;
    &lt;script&gt;
      function myFunction() {
        document.getElementById("demo").innerHTML = "line1\nline2\nline3\nline4\nline5\nline6";
      }
    &lt;/script&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>