Build an Email Masker - Build an Email Masker

Tell us what’s happening:

So I know I went a difficult route of doing this but what am I missing to pass? I feel like my answers should pass but they don’t.

Your code so far


let email = `removed by moderator`


function maskEmail(email){

  let start = email.indexOf(0)
  let end = email.indexOf("@") -1
  let hide = email.replace(email.slice(1, email.indexOf("@")-1), "*".repeat(end - start - 2))
  
  
  
  

  
  
  return console.log(hide)
}


maskEmail("apple.pie@example.com")
maskEmail("freecodecamp@example.com")
maskEmail("info@test.dev")
maskEmail("user@domain.org")
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/152.0.0.0 Safari/537.36 Edg/152.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

Welcome to the forum @bpmastin,

Your personal information has been removed from this post. Sharing personal information like your phone number, email, legal name and exact location online is unsafe.

It can be scraped by malicious actors to use against you, so please think carefully about what information you share.

What do user stories #2 and #3 say about how the email variable should be used?

Are you logging your function calls?

When you do this, your function returns undefined. To see what your function returns in the console, wrap your function calls in console.log().

Yeah, because I was returning the console log instead of the email itself, it wouldn’t give me the pass. After I changed it, I passed. Thank you for the idea, appreciate it.