Build an Email Masker - Output Correct, Error Remains

Tell us what’s happening:

Output is correct yet error remains. Kindly help, thanks.

Your code so far

function maskEmail(email) {
  const atPosition = email.indexOf("@");
  const localPart = email.slice(0, atPosition);
  const domain = email.slice(atPosition);
  const maskedLocal = localPart[0] + "*".repeat(localPart.length - 2) + localPart[localPart.length - 1];
  const maskedEmail = maskedLocal + domain;
  console.log("Masked email:", maskedEmail);
  return maskedEmail;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

Hi @MitchiMelon ,

Outside the function, declare a variable named email to store the email address you want to mask.

Does your code meet this requirement?

Also, please remove the console.log() inside your function and wrap your function calls in console.log() to see what your function returns in the console.

Happy coding!

thanks! need google’s help but made it without AI.