Skip to content

Instantly share code, notes, and snippets.

@neko-fire
Created May 3, 2012 09:45
Show Gist options
  • Save neko-fire/2584764 to your computer and use it in GitHub Desktop.
Save neko-fire/2584764 to your computer and use it in GitHub Desktop.
JavaScript: format number with leading zero
function formatNumber(number) {
return (number < 10 ? '0' : '') + number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment