Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I don’t understand how to do the rest of the steps after step 4. This should really have another workshop for stuff like this before a lab like this. It’s hard to know what to do if we don’t see it properly before hand.

Your code so far

function maskEmail(email) {let arobasePosition = email.indexOf("@");
let wordToSlice =email.slice(1, arobasePosition);
let wordToSliceCharCount = wordToSlice.lenght - 1;
let replacedChar= email.replace(wordToSlice, "*".repeat(wordToSliceCharCount));};

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0

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

Currently, your function is not returning anything.

Maybe try adding some logs within the function so you can see what your code is doing after each line.

oh console.log. I’ll tried that. Although I’m not sure how to do that.

Within the function, add console.log(wordToSlice) under that line of code. And repeat a log like that for each line to help you debug.

oki. I’ll try that. :slight_smile: Thank you for the help.

now I’m stuck again.

function maskEmail(email) {let arobasePosition = email.indexOf("@");
let wordToSlice =email.slice(1, arobasePosition);
console.log(wordToSlice);
let wordToSliceCharCount = wordToSlice.lenght - 1;
console.log(wordToSliceCharCount);
let replacedChar= email.replace(wordToSlice, "*".repeat(wordToSliceCharCount));
console.log(replacedChar);};

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

Please analyze your logs. Is wordToSlice what you expect it to be? If not, make an adjustment so it is. Then move on to the next log, etc.

I think this lab is way too hard. I’m gonna try tomorrow. but still don’t get how to get the results I want that’s the problem. if there was more specific help in the lab it would help. I know we did see everything but I have no idea how to suggest freecodecamp had another workshop for smth like this.

what steps would you take to hide an email like that if you had to do it manually?