Skip to content

Instantly share code, notes, and snippets.

@johnhutchins
Last active August 28, 2019 14:12
Show Gist options
  • Save johnhutchins/ba15cc80cd7fffa4f0ee6ffdb32aa045 to your computer and use it in GitHub Desktop.
Save johnhutchins/ba15cc80cd7fffa4f0ee6ffdb32aa045 to your computer and use it in GitHub Desktop.
// return masked string where only last 4 digits are shown
function maskify(cc) {
if (cc.length>4){
var masked = '';
for(i=0;i<cc.length-4;i++){
masked += cc[i].replace(cc[i], '#');
}
masked += cc.substring(cc.length-4, cc.length);
return masked;
} else {
return cc;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment