Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I have done the exercise, but it’s giving me this error: 9. Your maskEmail should produce the correct result.
I don’t really understand why this is happening, it seems like the correct results are being produced. What can I do?

Your code so far

const email = "example_email@gmail.com";

function maskEmail (email) {
  let indexNum = email.indexOf("@");
  let domain = email.slice(indexNum);
  let firstLetter = email.slice(0, 1);
  let lastLetter = email.slice(indexNum-1,indexNum);
  let slicedUser = email.slice(1,indexNum-1);
  let masked = slicedUser.replaceAll(/[a-zA-Z0-9#$%&._-]/g, "*");
  let maskedUser = firstLetter + masked + lastLetter + domain;
  return maskedUser;
}

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

Your browser information:

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

Challenge Information:

Build an Email Masker - Build an Email Masker

I got what was causing the issue. There had to be more special characters included. I added + and it seemed to work.