Tell us what’s happening:
I have been staring at this code for a while and I can’t tell why its returning an extra asterisk, nothing stands out to me as being particularly out of place. Can someone give me some pointers as to what specifically I need to alter? Cheers! ![]()
Your code so far
let email = "apple.pie@example.com";
function maskEmail(email) {
const address = email.indexOf("@")-1;
const slice = email.slice(1, address);
const mask = "*";
const replace = email.replace(slice, mask.repeat(address));
return(replace);
}
console.log(maskEmail(email))
email = "freecodecamp@example.com";
console.log(maskEmail(email));
email = "info@test.dev";
console.log(maskEmail(email));
email = "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/146.0.0.0 Safari/537.36
Challenge Information:
Build an Email Masker - Build an Email Masker