programming-examples/js/String/Hide email addresses to protect from unauthorized user.js
2019-11-15 12:59:38 +01:00

11 lines
373 B
JavaScript

protect_email = function (user_email) {
var avg, splitted, part1, part2;
splitted = user_email.split("@");
part1 = splitted[0];
avg = part1.length / 2;
part1 = part1.substring(0, (part1.length - avg));
part2 = splitted[1];
return part1 + "...@" + part2;
};
console.log(protect_email("robin_singh@example.com"));