title: Counting in binary
body: <p>I'm only learning to program and was trying to make a program to count in binary.</p>
  
  <p>I made a function that could convert the provided decimal to binary and it looks to be working just ok, but when I try to count upwards using a for loop my browser freezes and I can't understand why. Using a similar while loop produces the result I needed.</p>
  
  <p>The problem is right at the bottom commented out. Please help figure out what I'm doing wrong here.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>function isOdd(num) {return num % 2};
  
  var toBinary = function (number) {
   ints = [];
   binary = [];
   ints.push(Math.floor(number));
  
   while (number &gt;= 1) {
       number = (Math.floor(number))/2;
       ints.push(Math.floor(number));
   }
  
   for (i=ints.length-1;i&gt;=0;i--) {
       if (isOdd(ints[i])) {
           binary.push(1);
       } else {
           binary.push(0);
       }
   }
  
   if (binary[0] === 0) {
       binary.splice(0,1);
   }
  
   return binary;
  
  };
  
  var count = 0;
  while (count &lt;= 50) {
   console.log(toBinary(count));
   count++;
  }
  
  /*
  for (i=1;i&lt;=50;i++) {
   console.log(toBinary(i));
  }
  */
  </code></pre>