-
-
Save davidlonjon/7007136 to your computer and use it in GitHub Desktop.
Javascript: Quick pad
This file contains 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
function zeroPad(input, length, character){ | |
var padding = length + 1 - input.length; | |
return (padding > 0 ? Array(length + 1 - input.length).join(character || '0') + input : input); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment