title: Decimal to binary code-Javascript
body: <p>I'm trying to learn Javascript. Why this is not working?</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>function test() {
    var x,z;
    $x = document.getElementById("input").value;
    $z = ($x).toString(2);
    document.getElementById("demo").innerHTML = $z;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text" id="input"&gt;
  &lt;button onclick="test()"&gt;Try it&lt;/button&gt;
  &lt;p id="demo"&gt;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>