Build an Email Masker - Build an Email Masker

Tell us what’s happening:

All the tests ticked other than #4, keeps saying should assign a valid email to email variable. what’s the issue here?

Your code so far

function maskEmail (email) {
  const atPoint = email.indexOf("@") - 1;
  const slicedEmail = email.slice(1, atPoint);
  const theMask = "*";
  const masked = theMask.repeat(slicedEmail.length);
  const replacement = email.replace(slicedEmail, masked);
  return replacement;
};

let email = "apple.pie@example.com";
console.log(maskEmail(email));
maskEmail("freecodecamp@example.com");
console.log(maskEmail(email));
email = maskEmail("info@test.dev");
console.log(maskEmail(email));
email = maskEmail("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/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

Hi @Ruhollahbayani

You should assign a valid email address to your email variable.

You are not asked to assign a function call.

Happy coding

done. Thank you :+1: