Build an Email Masker - Build an Email Masker

Tell us what’s happening:

So I dont understand why the tests arent passing? When I console.log everything im getting the result that the test is asking for, which is the asterisks hiding the name except for the 0 index and the index before the ampersand. All I could think of is maybe the test wants to also have the quotations included

Your code so far

let email = "apple.pie@example.com";

function maskEmail(email){
  let star = "*";
  let emailNameSearch = email.indexOf("@");
  let maskedEmail = email.slice(1, emailNameSearch)
  let privateName = maskedEmail.replace(/./g, star);
  let reconstructedEmail = email.slice(0,1) + privateName + email.slice(emailNameSearch - 1);
  return reconstructedEmail;
}



console.log(maskEmail("apple.pie@example.com"));
console.log(maskEmail("info@test.dev"));
console.log(maskEmail("user@domain.org"));
console.log(maskEmail(email));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

Welcome back to the forum @joseedominguez92

Check how many masked characters your function returns.

console.log(maskEmail(“info@test.dev”)); // i***o@test.dev

Happy coding

1 Like

Thank you so much! I was just missing a difference! its funny after sitting there and beating my head up over it all day, stepping away and coming to your post literally fixed it in two seconds. Thank you so much for being a second pair of eyes!

1 Like