Build an Email Masker - Build an Email Masker

Tell us what’s happening:

Everything works… I just want to do it according to the code checker so I would get a check mark on this lab. Can someone please tell me how?

Your code so far

function maskEmail (email) 
{
  let findMiddle = email.indexOf("@") - 1;

  let takeMiddleCharacters = email.slice(1, findMiddle);
  
  let changedEmail = email.replace(takeMiddleCharacters, "*".repeat(findMiddle - 1));

  return console.log(changedEmail);
}

let email = "test@example.com";
maskEmail(email);
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-email-masker/66b205e6eacba4c4e54ea434.md at main · freeCodeCamp/freeCodeCamp · GitHub

if you write this, are you sure your function is returning what you want?

check it with

console.log("My function output is", maskEmail("apple.pie@example.com"));