Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I feel like I’ve had this problem for a while and even after seeing the other help posts, I’m having a hard time figuring out why this code doesn’t pass the test. please help

Your code so far

Summary

This text will be hidden

function maskEmail(email) {
  let atIndex = email.indexOf('@');
  let username = email.slice(0, atIndex);
  let domain = email.slice(atIndex);
  
  let maskedEmail = username[0] + "*".repeat(username.length - 2)+ username[username.length - 1] + domain;
  return console.log(`"${maskedEmail}"`);
}

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

email = "freecodecamp@example.com";
maskEmail(email);

email = "info@test.dev";
maskEmail(email);

email = "user@domain.org";
maskEmail(email);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

This text will be blurred

Summary

This text will be hidden

Hi @techemail4

Try removing the quote marks from the output.

  1. Call the maskEmail function with the email variable and output the result to the console.

You are asked to console log the function call, not console log what the function returns.

Happy coding

Hi Teller!

i will post the code without the quotes so you know i can do it lol but i’ve already tried to submit without the quotes to no avail. I added them because it wasnt working so i assumed i needed to reread how the lab describes the answer , which explicitly uses quotes.

function maskEmail(email) {

let atIndex = email.indexOf(‘@’);

let username = email.slice(0, atIndex);

let domain = email.slice(atIndex);

let maskedEmail = username[0] + “*”.repeat(username.length - 2)+ username[username.length - 1] + domain;

return console.log(maskedEmail);

}

let email = “apple.pie@example.co m”;

maskEmail(email);

email = “freecodecamp@example.com”;

maskEmail(email);

email = “info@test.dev”;

maskEmail(email);

email = “user@domain.or g”;

maskEmail(email);

//ignore the spaces in the links//

Please remove the console log after the return statement.

Return just the maskedEmail variable.

For user story 4 and test 10, after the email variable, log a function call, using email as the parameter.

Thank you Teller! removing the log from after return and then inserting one logging maskEmail(email) worked ~