Zero-padding a number to have six digits This is a switch statement in JavaScript. I have a feeling that it can be done in a shorter way.

switch(n.length){
  case 1:
    n = '00000' + n;
  break;
  case 2:
    n = '0000' + n;
  break;
  case 3:
    n = '000' + n;
  break;
  case 4:
    n = '00' + n;
  break;
  case 5:
    n = '0' + n;
  break;
}
function foobar(n)
{
    var zeroes = "000000";
    return zeroes.substr(n.length) + n.toString();
}