Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I’ve managed to complete the lab and successfully mask the email. When I want to check the assignment, it says my function doesn’t return the desired result, even though the console outputs the masked email. I’ve tested all four emails, and it comes out correctly. There’s also an undefined result that keeps appearing and I’m not sure why. Please assist

Your code so far

function maskEmail(email) {

  const delimiter = "@";
  const index = email.indexOf(delimiter);
  const maskUser = email.substring(0, index);
  const firstLetter = maskUser.substring(0, 1);
  const lastLetter = maskUser.slice(-1);
  const domain = email.slice(index)

  const mask = maskUser.slice(1, -1);
  const maskLength = mask.length;
  const asterisk = '*';
  const censor = asterisk.repeat(maskLength);

  const maskedEmail = firstLetter + censor + lastLetter + domain
  
  console.log(maskedEmail)

}

let email = "apple.pie@example.com"

console.log(maskEmail(email))

Your browser information:

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

Challenge Information:

Build an Email Masker - Build an Email Masker

Hi there,

Your function is not returning anything. It’s only logging to the console.

Happy coding!

Lesson learned, thank you so much! :grin:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.