Build an Email Masker - Build an Email Masker

Tell us what’s happening:

Please help me identify the bugs with my code! It is not passing step 5 upto the last one.

Your code so far


let email = "mymaskedemail@gmail.com";

function maskEmail(email) {
 let atIndex = email.indexOf("@");
 let sliced = email.slice(1, (atIndex - 1));
 console.log(sliced);
 let mask = "*";
 let maskedEmail = email.replace(sliced, mask.repeat(atIndex));
 console.log(maskedEmail);
}

maskEmail(email);
maskEmail("freecodecamp@example.com");
maskEmail("info@test.dev");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

what is your function returning?

I have resolved the issue by adding the Return statement! Thank you for assisting.

1 Like