Tell us what’s happening:
What am I doing wrong. Getting result as asked but why it’s not passing.
Your code so far
function maskEmail(email){
let index =email.indexOf("@");
let afterCut = email.slice(index-1);
let newMail = "*".repeat(index)+afterCut;
let finalMail = newMail.replace("*", email.at(0));
return finalMail;
}
let email ="apple.pie@example.com";
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/142.0.0.0 Safari/537.36 Edg/142.0.0.0
Challenge Information:
Build an Email Masker - Build an Email Masker