Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I believe i understand the HOW of this project but i don’t know how to even begin to write the code. I understand using indexOf and Slice to extract he two parts of the email, then (somehow) manipulating the beginning (possibly using replace) then merging the two strings back together. I just can even figure out how to write the actual code. The fact tat each email can vary in length is throwing me off as well. Not sure if anyone can help me or how to help me without giving me the answer.

Your code so far

let email = "example@example.com"

function maskEmail(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/150.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

Welcome :waving_hand:

You have got a decent start there following the user stories. I suggest continuing with bits you are sure about:

a. You know you want to extract the email into two parts
b. You know you want to manipulate one of those parts
c. You know you want to merge the two together
d. You know you want maskEmail to return something

Sometimes, I work backwards in the code. Try adding more to your function, but start from the “bottom” - add a return statement. Come up with an apt variable name for what you want to return.

Then, move up. Declare that returned variable, and assign it a value based on step c - merging two somethings together. Come up with apt variable names for those somethings.

Do that, and see how far you can get from there.

All emails are basically patterned like username@domain. What’s the one character that is always consistent? Try using that character to get at the substring that needs to be replaced in the username.