title: Get all text as a string from page
body: <p>I want to get all the text from an html page into a string a print it on the console. So far I have this piece of code that works only partially because document.body.innerText returns the text together with line brakes which I certainly dont want. I want all my text to appear in 1 line</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;h1&gt;wtf&lt;/h1&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div&gt;dddiiiv&lt;/div&gt;
          &lt;a&gt;aaaaa&lt;/a&gt;
          &lt;p&gt;ppp&lt;/p&gt;
          &lt;div&gt;div&lt;/div&gt;
          &lt;div id="impar"&gt;&lt;/div&gt;
          &lt;div id="par"&gt;&lt;/div&gt;
          &lt;div id="all"&gt;&lt;/div&gt;
          &lt;script&gt;
              var elems = document.body.innerText;
              var odd = "";
              var even = "";
              var all = "";
              for (k in elems){
                  all = all + elems[k];
                  if (k % 2 === 0) {
                      even = even + elems[k]
                  } else {
                      odd = odd + elems[k]
                  }
              }
  
  
              console.log(all);
              console.log(odd);
              console.log(even);
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any idea of a get around for the innerText's brakes?</p>