Skip to content

Instantly share code, notes, and snippets.

@WagnerMoreira
Last active April 12, 2023 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WagnerMoreira/04c74daa3a9ac6f712e5a0ec648b46a7 to your computer and use it in GitHub Desktop.
Save WagnerMoreira/04c74daa3a9ac6f712e5a0ec648b46a7 to your computer and use it in GitHub Desktop.
left pad string (pad start), isArray, isPositiveInt
function leftPad(str, padLength) {
const arr = str.split(" ")
Array.from(Array(padLength).keys()).forEach(x => arr.push(" "))
return arr.reverse().join().replace(/,/g, '')
}
const isArray = (x) => x.hasOwnProperty('length');
const isPositiveInt = (n) => n > 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment