Last active
November 19, 2015 15:10
-
-
Save andreasvirkus/9a6130b8055335614ef9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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