Skip to content

Instantly share code, notes, and snippets.

@voidnerd
Last active September 11, 2018 15:08
Show Gist options
  • Save voidnerd/96a14c023a7e4ef2697305f6ee5c0ce2 to your computer and use it in GitHub Desktop.
Save voidnerd/96a14c023a7e4ef2697305f6ee5c0ce2 to your computer and use it in GitHub Desktop.
function encrypt(str, num) {
let len = str.substring(num, str.length - num).length;
let goin = '*'.repeat(len);
let res = str.slice(0, num) + goin + str.slice(str.length - num);
return res;
}
console.log(encrypt('111111111111111111111111111', 4)); // 1111*******************1111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment