Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I’m testing my emails after doing the function, and they are correct, but the tests still have crosses in them

Your code so far

function maskEmail(email){ 
  let indexer = (email.indexOf('@')-1); 
  let slicer = email.slice(1,indexer); 
  let hide = '*'; 
  let replaced = email.replace(slicer,hide.repeat(indexer)); 
  return(replaced) } 
let email = "apple.pie@example.com";
console.log(maskEmail(email));
  

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/28.0 Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

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

Your output:a********e@example.com

Looks the same.

a*******e@example.com
a********e@example.com

But it’s not the same

I’ve just noticed that in the first example. How do I stop the “hide” part from including the dot as a character?

Maybe you could replace it with nothing first?

Are you sure that’s the problem?

a*******e@example.com
a********e@example.com
apple.pie@example.com

@Estee Did you test this? Because it does not work.

That said,

instead of posting a working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method