Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I’m getting the correct results but do not pass the tests.

What do i need to do to pass the tests?

Here’ are the messages:
5.

maskEmail("apple.pie@example.com")

should return

"a*******e@example.com"

. 6.

maskEmail("freecodecamp@example.com")

should return

"f**********p@example.com"

. 7. Your

maskEmail

should produce the correct result.

Your code so far

function maskEmail(email){
  
  let sign = email.indexOf("@");
 // console.log(sign);

  let lc = email.slice(sign-1);
  // console.log(lc);

  let fc = email.charAt(0)
  //console.log(fc);
  let domain = email.slice(1,sign)
  // console.log(domain);
  
  let mask = "*";
  // console.log(mask);

  let maskL = domain.length;
  // console.log(maskL);

  let repeating = mask.repeat(maskL);
  //console.log(repeating);

  let replaced = domain.replace(domain,repeating);
  //console.log(replaced);

  return fc + replaced + lc;

}

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

Here are the messages:

  1. maskEmail(“apple.pie@example.com”) should return “a*******e@example.com”.
  2. maskEmail(“freecodecamp@example.com”) should return “f**********p@example.com”.
  3. Your maskEmail should produce the correct result.

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15

Challenge Information:

Build an Email Masker - Build an Email Masker

Here’s a hint. One of the characters at the back is being represented twice. A masked email address would still have the same character length of the original email address.