Build an Email Masker - Build an Email Masker

Tell us what’s happening:

The code works fine, but it won’t accept is as valid, hence, not letting me continue. It also says that the returned value is wrong, even though is not.

Your code so far

const email = "apple.pie@example.com"

function maskEmail(email) {
  const last = email.indexOf("@") - 1;
  const initial = 1;
  const sliced = email.slice(initial, last);
  const masked = "*".repeat(sliced.length);
  const final = email[0] + masked + email[last] + email.slice(last + 1);

  console.log(final);
}

maskEmail(email);

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

Make sure to follow the instructions exactly for the tests to pass. The code may work fine, but re-read what it’s asking for in the section. I think the fix is changing console.log(final) to return . Try that and let me know what you get.