Skip to content

Instantly share code, notes, and snippets.

@leonidkuznetsov18
Last active July 18, 2018 11:01
Show Gist options
  • Save leonidkuznetsov18/9949272fe29f0574038e3dd695065be1 to your computer and use it in GitHub Desktop.
Save leonidkuznetsov18/9949272fe29f0574038e3dd695065be1 to your computer and use it in GitHub Desktop.
// return masked string
function maskify(cc) {
return cc.replace(/.(?=.{4})/g, "#");
}
// or
function maskify(cc) {
return cc.replace(/.(?=....)/g, '#');
}
// or
function maskify(cc) {
return cc.slice(0, -4).replace(/./g, '#') + cc.slice(-4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment