Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I know I should do something with the repeat() methode. but I dont know how tot use it cause you can only put a number in repeat(0) to make it work (that’s how I understood it). But how much it needs to repeat depends on the email. So an someone give me a tip on how to continue, I have the feeling im almost there so i want make it right!

Your code so far

 function maskEmail(emailing) {
  let emailIndex = emailing.indexOf("@");
  let sliceBefore = emailing.slice(1, emailIndex -1);
  let replaceEmail = emailing.replace(sliceBefore, "*")
  
  return replaceEmail
}

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

Your browser information:

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

Challenge Information:

Build an Email Masker - Build an Email Masker

Check these MDN repeat() examples to see how to use that method:

String.prototype.repeat() - JavaScript | MDN

Also, are you sure emailing is the parameter name that should be defined in maskEmail()?

Good luck!

Thanks for the quick response and the tip. Took me some time to figure it out but I did!!

Please create your own topic using the “Ask for Help” button, which will auto-populate your post with your current code and the URL to the challenge. This button becomes visible after testing three times without success.

Thank you.