I feel like I’ve had this problem for a while and even after seeing the other help posts, I’m having a hard time figuring out why this code doesn’t pass the test. please help
Your code so far
Summary
This text will be hidden
function maskEmail(email) {
let atIndex = email.indexOf('@');
let username = email.slice(0, atIndex);
let domain = email.slice(atIndex);
let maskedEmail = username[0] + "*".repeat(username.length - 2)+ username[username.length - 1] + domain;
return console.log(`"${maskedEmail}"`);
}
let email = "apple.pie@example.com";
maskEmail(email);
email = "freecodecamp@example.com";
maskEmail(email);
email = "info@test.dev";
maskEmail(email);
email = "user@domain.org";
maskEmail(email);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36
i will post the code without the quotes so you know i can do it lol but i’ve already tried to submit without the quotes to no avail. I added them because it wasnt working so i assumed i needed to reread how the lab describes the answer , which explicitly uses quotes.
function maskEmail(email) {
let atIndex = email.indexOf(‘@’);
let username = email.slice(0, atIndex);
let domain = email.slice(atIndex);
let maskedEmail = username[0] + “*”.repeat(username.length - 2)+ username[username.length - 1] + domain;
return console.log(maskedEmail);
}
let email = “apple.pie@example.co m”;
maskEmail(email);
email = “freecodecamp@example.com”;
maskEmail(email);
email = “info@test.dev”;
maskEmail(email);
email = “user@domain.or g”;
maskEmail(email);
//ignore the spaces in the links//