Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Last active November 19, 2015 15:10
Show Gist options
  • Save andreasvirkus/9a6130b8055335614ef9 to your computer and use it in GitHub Desktop.
Save andreasvirkus/9a6130b8055335614ef9 to your computer and use it in GitHub Desktop.
/**
* Prefix an integer with 0-s (zeros), resulting in the specified length
*
* @param num int integer to prepend
* @param length int length of the desired number
*/
function prefixInteger(num, length) {
return (Array(length).join('0') + num).slice(-length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment