Tell us what’s happening:
I am getting the required output but still failing the tests.
Your code so far
let email = "freecodecamp@example.com";
let secLastLetBeforeAt = email.indexOf("@") - 1;
let secLet = email.slice(1);
let stars = "*".repeat(secLastLetBeforeAt - 1);
function maskEmail(email) {
return `"${email[0]}${stars}${email.slice(secLastLetBeforeAt)}"`;
}
console.log(maskEmail(email));
email = "apple.pie@example.com";
secLastLetBeforeAt = email.indexOf("@") - 1;
secLet = email.slice(1);
stars = "*".repeat(secLastLetBeforeAt - 1);
console.log(maskEmail(email));
email = "user@domain.org";
secLastLetBeforeAt = email.indexOf("@") - 1;
secLet = email.slice(1);
stars = "*".repeat(secLastLetBeforeAt - 1);
console.log(maskEmail(email));
email = "info@test.dev";
secLastLetBeforeAt = email.indexOf("@") - 1;
secLet = email.slice(1);
stars = "*".repeat(secLastLetBeforeAt - 1);
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/143.0.0.0 Safari/537.36
Challenge Information:
Build an Email Masker - Build an Email Masker