title: Increment a number with a max length
body: <p>Currently in my application I have an increment logic as below, and it fails now when <code>b</code> value above <code>9</code> (i.e <code>00010</code>, <code>00011</code>). As the limit is 4 digits which should become <code>0010</code>, <code>0011</code> and so on. </p>
  
  <p>How can i make value to <code>0010</code> instead of <code>00010</code></p>
  
  <pre><code>var b = 0; 
  for (var p = 0; p &lt; tabarray.length; p++)
  { 
     b = b + 1; 
     tabarray[p].ItemKey = "000" + b; 
  }
  </code></pre>