Last active
March 24, 2016 19:12
-
-
Save erikjung/d2e6dc2c33c61b0ccfde to your computer and use it in GitHub Desktop.
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
module.exports = function leftpad (str, len, ch) { | |
const val = String(str); | |
const pad = ch === undefined ? ' ' : String(ch); | |
return pad.repeat(Math.max(0, len - val.length), pad) + val; | |
}; |
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
{ | |
"name": "left-pad", | |
"main": "left-pad.js", | |
"version": "0.0.1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment