title: How To Write Object To Document with document.write()
body: <p>I have a simple app that counts repeating numbers inside of an array. 
  Users enter numbers through prompt (i.e. 2, 1, 2, 2). </p>
  
  <p>And when I want to output the result (which is an object) through document.write() function I get: 
  [object Object]</p>
  
  <p>When I output it through console I get the result I expect:
  Object {2: 3, 1:1}</p>
  
  <p>Down below is html and js, and Plunkr can be found <a href="http://plnkr.co/edit/hTd5vtJu3f0YSkjMkN8E?p=preview" rel="nofollow noreferrer">here</a></p>
  
  <p>I would like the results of the object to be written on the page...</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;!--    JAVASCRIPT AND JQUERY STUFF --&gt;
  &lt;script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"&gt;
  
  &lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"&gt;
  
  &lt;/script&gt;
  &lt;script src="number-list.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Enter numbers when prompted!&lt;/h1&gt;
  &lt;p&gt;Here are the numbers entered on the left and frequency of occurence on the right.&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>JAVASCRIPT</p>
  
  <pre><code>$(document).ready(function(){
  var n = prompt("Enter your numbers").split(",");
  console.log(n);
  var counts = {};
  n.forEach(function(x){ 
  counts[x] = (counts[x] || 0) +1; 
  });
  console.log(counts);
  document.write(
  "&lt;h1&gt;Enter numbers when prompted!&lt;/h1&gt;" +
  "&lt;p&gt;You entered following numbers:&lt;/p&gt;" + n + "&lt;br/&gt;" +
  "&lt;p&gt;The occurence is as follows:&lt;/p&gt;" + counts);
  });
  </code></pre>