Tell us what’s happening:
My code is long winded but it returns the desired results, it produces the correct outcome for both example emails but i’m stuck as to why it’s not passing on ‘7. Your maskEmail should produce the correct result.’
Thanks for any help!
Your code so far
const maskEmail = (email) => {
const domainRemoved = email.slice(0, -12);
const emailSlice = domainRemoved.slice(1, -1);
const starSlice = emailSlice.replace(emailSlice, '*');
const repeatStar = starSlice.repeat(emailSlice.length);
const firstChar = domainRemoved.charAt(0);
const lastChar = domainRemoved.charAt(domainRemoved.length -1);
const domainName = '@example.com';
return `${firstChar}${repeatStar}${lastChar}${domainName}`;
}
let email = "apple.pie@example.com";
console.log(maskEmail(email));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Challenge Information:
Build an Email Masker - Build an Email Masker