JavaScript: Hide email addresses to protect from unauthorized user - w3resource

PHOTO EMBED

Sat Oct 01 2022 05:42:51 GMT+0000 (Coordinated Universal Time)

Saved by @Anah #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"));


content_copyCOPY

https://www.w3resource.com/javascript-exercises/javascript-string-exercise-6.php