title: Function to convert Number to Binary string
body: <p>Writing a function to convert passed in number to a binary string. The function is creating a proper binary sequence, but my compare function is skipping the first index when comparing a number equal to <code>binaryIndex[0]</code> (ex. n = 32, 16, 8, 4). Any ideas why?</p>
  
  <p>This step creates a binary ordered array, which is what I will use to check the passed in parameter with: </p>
  
  <pre><code>var Bin = function(n) {
    var x =1;
    var binSeq=[];
    var converted=[];
    for (var i=0; x &lt;= n; i++) {
    binSeq.unshift(x)
    x = x+x
    }
    console.log(binSeq)
  </code></pre>
  
  <p>This next step should compare and spit out a binary sequence of 1's and 0's: but it is skipping <code>if (n === binSeq[0])</code></p>
  
  <pre><code>for (var i=0; i &lt; binSeq.length; i++) {
    if ((n - binSeq[i]) &gt;= 0) {
    converted.unshift(1);
    n=n-binSeq[i]
    } else {converted.unshift(0)}
  }
  console.log(converted)
  }
  </code></pre>
  
  <p>Link to the CodePen: <a href="https://codepen.io/fdeppe/pen/GEozKY?editors=1111" rel="nofollow noreferrer">https://codepen.io/fdeppe/pen/GEozKY?editors=1111</a></p>