Created
May 11, 2015 09:18
-
-
Save MattiasFestin/4669d2eb18d20e8e0fc6 to your computer and use it in GitHub Desktop.
String padding (Requires propper tail calls)
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
let padLeft = (value, char, n) => n - value.length > 0 ? padLeft(char + value, char, n-1) : value; | |
let padRight = (value, char, n) => n - value.length > 0 ? padRight(value + char, char, n-1) : value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment