Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I’m really stuck please help. I don’t understand what’s required of me?

Your code so far

function maskEmail(email){
  const [username, domain] = email.split("@");
  if (username.length <= 2) "*****@" + domain;
  return `${username[0]}*****${username[username.length - 2]}@${domain}`;
}
let email = "apple.pie@example.com";
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; rv:153.0) Gecko/20100101 Firefox/153.0

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

Hi @malvo,

It looks like you’re hard coding the asterisks, but those should be dynamically determined.

Look at the expected pattern. Only the first letter and last letter in username are retained. The other letters are replaced with asterisks.

Happy coding