Build an Email Masker - Build an Email Masker

Tell us what’s happening:

All the tests have been passed except for 9th, even though my output is correct.

Your code so far

function maskEmail(email){
  email = email.replace("pple.pi", "*******");
  email = email.replace("reecodecam", "**********");
  email = email.replace("nf", "**");
  email = email.replace("se", "**");
  return email;
}
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

It looks like you have hard-coded conditionals or variables that check for specific expected values. That is not solving this problem in the general case. Imagine if you were given different input values. Would your code be able to solve those problems?

To find out more about what hard-coding is or about why it is not suitable for solving coding questions, please read this post: Hard-coding For Beginners

Let us know if you have a question about how to make your code more flexible.

Thank you I changed the code up and now it solved.