Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I think my program works correctly (Build an Email Masker), but it didn’t pass the test when I submitted it . It keeps on throwing the test 7 stating that Your maskEmail should produce the correct result even after the rest of the tests passes.

Your code so far

function maskEmail(email){
  let maskedEmail = email.slice(1, -13)
  let maskedNumber = "*";
  let maskedLength = maskedEmail.length;
  let repeatedValue = maskedNumber.repeat(maskedLength)
  
  let latestemail = email.replace(maskedEmail , repeatedValue)
  console.log(latestemail);
  return latestemail;
  }


let email;
email = "ekomjahedet@example.com";
console.log(maskEmail(email));
maskEmail("freecodecamp@example.com")


Your browser information:

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

Challenge Information:

Build an Email Masker - Build an Email Masker

try checking what maskEmail("freecodecamp@xam.com") return

It returns this: f******ecamp@xam.com

and is that correct?

No. I was of the opinion that since all the tests required was an email with the domain @example.com, that it what the maskemail should also work with

you are failing the one that does not show the email it is testing, so try making it work with any email length

But which string method could work for that

slice can still be useful, but you need to approch this in a slightly different way

you can also not use string methods at all, there are many ways to solve this

Ok. Let me try the slice approach

I tried this now and it works. Thanks!