Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I’m not quite sure what’s happening here. My maskEmail function works perfectly well here; all of my inputs give the asked for output, with no errors whatsoever. I also tried allowing email to equal input, then logging it (ex: let email = “hi@example.com”, then console.log(email)), but to no avail. All steps after 4 are counted as incorrect.

Your code so far

function maskEmail(email){
  let cutEmail = email.slice(1, email.indexOf("@") - 1)

  email = email.replace(cutEmail, "*".repeat(cutEmail.length))

  return console.log(email);
}

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

maskEmail("apple.pie@example.com")
maskEmail("freecodecamp@example.com")
maskEmail("info@test.dev")
maskEmail("useer@domain.org")


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 OPR/133.0.0.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

Double check what you are returning.

return and console.log() are two different things and should not really be combined.

return defines what a function returns.
console.log() logs something to the console.

Two totally different actions. Double check what is being asked.

  1. maskEmail("apple.pie@example.com") should return "a*******e@example.com".

If you want to call a function and see what it returns, you can wrap the function call in a console.log

console.log(maskEmail("apple.pie@example.com"))