Build an Email Masker - Build an Email Masker

Tell us what’s happening:

Hi, I really don’t know how to progress with this, can someone help me?

Your code so far

function maskEmail (email)
{
  return ${email};
email = "apple.pie@example.com"
let email = maskEmail.replace ("pple.pi", "*******");

email = "freecodecamp@example.com"
let email = maskEmail.replace ("reecodecam", "**********");

email = "info@test.dev"
let email = maskEmail.replace ("nf", "**");

email = "user@domain.org"
let email = maskEmail.replace ("se", "**");
}
let email

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/143.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.

other than the hardcoding issue, do you know what happens when a return statement is executed?

How can I make it more flexible?

function maskEmail (email)

{

return email;

email = “apple.pie@example.com

let maskEmail = email.replace (“pple.pi”, “*******”);

email = “freecodecamp@example.com

let maskEmail = email.replace (“reecodecam”, “**********”);

email = “info@test.dev”

let maskEmail = email.replace (“nf”, “**”);

email = “user@domain.org

let maskEmail = email.replace (“se”, “**”);

}

let email

console.log(maskEmail(email));

my code looks like this right now, so is it ok that I deleted the ${?

you need to write code that works for any email address, you should not hardcode the part of the email to replace

your code is only doing this, because a return stops the function