Tell us what’s happening:
I have finished my code and getting the desired result, masking the characters in between the first and last letters of the username. However, my code wnt go through and stuck at number 5.
Your code so far
let email = "apple.pie@example.com";
function maskEmail(email) {
const splitEmail = email.toLowerCase().split("@");
const splitUsername = splitEmail[0].split("");
const charToBeReplaced = splitUsername.slice(1, -1);
const asterisk = "*";
const numOfAsterisk = asterisk.repeat(charToBeReplaced.length);
const newEmail = `"${splitUsername[0]}${numOfAsterisk}${splitUsername[splitUsername.length - 1]}@${splitEmail[1]}"`;
return newEmail;
}
maskEmail(email);
console.log(maskEmail("apple.pie@example.com"));
console.log(maskEmail("freecodecamp@example.com"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Challenge Information:
Build an Email Masker - Build an Email Masker