Build an Email Masker - Build an Email Masker

Tell us what’s happening:

Can’t seem to get step 5 to 9 to pass, what am I doing wrong?

Your code so far

function maskEmail(email) {
  let findAt = email.indexOf("@");
  let username = email.slice(1, findAt-1);
  const usernameLength = username.length;
  let asterisk = "*";
  let asteriskRepeat = asterisk.repeat(usernameLength);
  let result = email.replace(username, asteriskRepeat);

  return result
}

let email = "apple.pie@example.com";
console.log(maskEmail(email));

email = "freecodecamp@example.com";
console.log(maskEmail(email));

email = "info@test.dev";
console.log(maskEmail(email));

email = "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/143.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

Your code passes the test when I try it.

You can try to reset the lab and copy/paste this code back in and try it

1 Like