Skip to content

Instantly share code, notes, and snippets.

@MattiasFestin
Created May 11, 2015 09:18
Show Gist options
  • Save MattiasFestin/4669d2eb18d20e8e0fc6 to your computer and use it in GitHub Desktop.
Save MattiasFestin/4669d2eb18d20e8e0fc6 to your computer and use it in GitHub Desktop.
String padding (Requires propper tail calls)
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