title: How to route the value of a JS variable to an HTML Div?
body: <p>Hey guys I'm totally new here and need help on an assignment. Last week we created a simple JS program that converts decimal to binary (without using parseint). The new assignment is to prompt the user for a decimal number, then display the resulting binary number in 8 separate div elements. </p>
  
  <p>Although there might have been a more succinct way to do the conversion, here is what I did within javascript. For clarification I named the variables with respect to their corresponding base two power (2^7 place, 2^6 place, etc)</p>
  
  <pre><code>var seven = 0;
  var six = 0;
  var five = 0;
  var four = 0;
  var three = 0;
  var two = 0;
  var one = 0;
  var zero = 0;
  
  var input = document.getElementById("dec").value;
  
  if (input &lt; 128) {
    seven = 0;
  }
  
  if (input &gt; 128) {
    input = input % 128;
    seven = 1;
  }
  
  if (input &lt; 64) {
    six = 0;
  }
  
  if (input &gt; 64) {
    input = input % 64;
    six = 1;
  }
  
  if (input &lt; 32) {
    five = 0;
  }
  
  if (input &gt; 32) {
    input = input % 32;
    five = 1;
  }
  
  if (input &lt; 16) {
    four = 0;
  }
  
  if (input &gt; 16) {
    input = input % 16;
    four = 1;
  }
  
  if (input &lt; 8) {
    three = 0;
  }
  
  if (input &gt; 8) {
    input = input % 8;
    three = 1;
  }
  
  if (input &lt; 4) {
    two = 0;
  }
  
  if (input &gt; 4) {
    input = input % 4;
    two = 1;
  }
  
  if (input &lt; 2) {
    one = 0;
  }
  
  if (input &gt; 2) {
    input = input % 2;
    one = 1;
  }
  
  if (input &lt; 1) {
    zero = 0;
  }
  
  if (input = 1) {
    zero = 1;
  }
  </code></pre>
  
  <p>Here is what I've done in html. (We use codepen.io, which does not require body tags)</p>
  
  <pre><code>&lt;form&gt;
    &lt;input type="number" id="dec" min="0" max="255" step="1" /&gt;
  &lt;/form&gt;
  
  &lt;div id="seventh"&gt;0&lt;/div&gt;
  &lt;div id="sixth"&gt;0&lt;/div&gt;
  &lt;div id="fifth"&gt;0&lt;/div&gt;
  &lt;div id="fourth"&gt;0&lt;/div&gt;
  &lt;div id="third"&gt;0&lt;/div&gt;
  &lt;div id="second"&gt;0&lt;/div&gt;
  &lt;div id="first"&gt;0&lt;/div&gt;
  &lt;div id="zeroth"&gt;0&lt;/div&gt;
  </code></pre>
  
  <p>So getting down to the real question, once the user inputs a decimal number and I have the binary units saved to their corresponding variables, how do I route the value of these variables to the div elements I created in HTML? </p>
  
  <p>Thanks so much for your help guys.</p>