Skip to content

Instantly share code, notes, and snippets.

@asifvora
Created March 15, 2019 05:44
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 asifvora/93c9ebc63501b7c455731ef3a6617aeb to your computer and use it in GitHub Desktop.
Save asifvora/93c9ebc63501b7c455731ef3a6617aeb to your computer and use it in GitHub Desktop.
Create a function that masks a string of characters with # except for the last four (4) characters.
const mask = (str, maskChar = "#") => str.slice(-4).padStart(str.length, maskChar);
mask("123456789"); // "#####6789"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment