Created
September 1, 2017 06:37
-
-
Save xexi/5262db7792bca8c767ed84bd3dee099e to your computer and use it in GitHub Desktop.
js zerofill (positive)
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 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