Tell us what’s happening:
Been trying to figure out what’s wrong with my code, but I just can’t wrap my head around it. The output is exactly the same as required, and yet it fails the tests. Am I doing it wrong?
Your code so far
function maskEmail(email) {
const address = email.indexOf("@");
const slice = email.slice(1, address-1);
const sliceInitial = email.slice(0, 1);
const sliceRest = email.slice(address-1);
const sliceName = slice.replace(slice, "*").repeat(address-1);
return sliceInitial+sliceName+sliceRest;
}
let email= "apple.pie@example.com";
console.log(maskEmail(email));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Challenge Information:
Build an Email Masker - Build an Email Masker