For some reason I can’t get the site to accept my answer. I’ve ran some tests within the code to make sure my output matches what the correct answer are, and they all come back as true. Below is my code and the results in the console. Any suggestions would be appreciated.
function maskEmail(emailMask) {
let hidden = "*";
let maskedEmail = email[0] + hidden.repeat(email.indexOf("@") - 2) + email[email.indexOf("@") - 1] + email.slice(email.indexOf("@"));
// testing redacted email matches answer
if (maskedEmail === "a*******e@example.com") {
console.log(true);
} else if (maskedEmail === "f**********p@example.com") {
console.log(true);
} else if (maskedEmail === "i**o@test.dev") {
console.log(true);
} else if (maskedEmail === "u**r@domain.org") {
console.log(true);
}
return maskedEmail;
}
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));