Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function emailEncodeLenght(addressLength) {
- let result = '';
- let x = addressLength;
- for (var i = 0; i < x; i++ ) {
- if (i <= x) {
- result += '*'
- }
- }
- return result;
- }
- function protectEmail(userEmail) {
- var avg, splitted, part1, part2;
- splitted = userEmail.split("@");
- part1 = splitted[0];
- avg = part1.length -1;
- part1 = part1.substring(0, (part1.length - avg));
- part2 = splitted[1];
- return part1 + emailEncodeLenght(splitted[0].length -1) + part2;
- };
- protecEmail('someemailaddress@gmail.com') //output: s***************@gmail.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement