Tell us what’s happening:
I don’t know what I am doing wrong here, why isn’t it saying task complete? Code seems to work as asked.
Your code so far
function maskEmail(email) {
//slice part before email.com
const emailTail = email.slice(email.indexOf('@'));
const emailHead = email.slice(0, email.indexOf('@'));
let masked = emailHead;
for (let i = 0; i < emailHead.length; i++) {
if (i != 0 || i != email.length) {
masked = masked.replace(emailHead[i], '*');
}
}
return emailHead[0] + masked + emailHead[emailHead.length - 1] + emailTail;
}
const email = "info@test.com";
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/138.0.0.0 Safari/537.36 Edg/138.0.0.0
Challenge Information:
Build an Email Masker - Build an Email Masker
https://www.freecodecamp.org/learn/full-stack-developer/lab-email-masker/build-an-email-masker