Skip to content

Instantly share code, notes, and snippets.

@xexi
Created September 1, 2017 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xexi/5262db7792bca8c767ed84bd3dee099e to your computer and use it in GitHub Desktop.
Save xexi/5262db7792bca8c767ed84bd3dee099e to your computer and use it in GitHub Desktop.
js zerofill (positive)
function zerofill(number, length) {
// Setup
var result = number.toString();
var pad = length - result.length;
while(pad > 0) {
result = '0' + result;
pad--;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment