title: Convert number to tens, hundreds, thousands
body: <p>I need a function that, given a number, say, 123, will output an array [100,20,3]. I've tried something like this (borrowed from another question on SO):</p>
  
  <pre><code>function separateNumberIntoUnits(n) {
      var arr = [];
      var i = 10;
  
      while (n &gt; i / 10)
      {
          arr.unshift(n % i - n % (i / 10));
          i *= 10;
      }
  
      return arr;
  }
  </code></pre>
  
  <p>and it works for all numbers except for 10, 100 etc. I've tried to figure out what's going on, but math isn't my strong side...</p>
  
  <p>If there's a more efficient way to do this, feel free to write your own solution.</p>