// n = number you want padded // digits = length you want the final output function blankPad(n, digits) { n = n.toString(); while (n.length < digits) { n = ' ' + n; } return n; }
Programming Tips - javaScript has no sprintf() ... how can I blank pad a number?
Date: 2008may13
Language: javaScript
Q. javaScript has no sprintf() ... how can I blank pad a number?
A. Use this function: