Tell us what’s happening:
All the tests work except apple.pie. The masked email seems to retain the “e” at the end of it. Should I create a special case where an email address has an “e” at the end?
Your code so far
function maskEmail(email) {
const toAt = email.indexOf("@");
const emailName = email.slice(0, toAt);
return emailName[0] + "*".repeat(emailName.length-1) + "@" + email.slice(toAt+1);
}
let email = "apple.pie@example.com";
console.log(maskEmail(email));
console.log(maskEmail("freecodecamp@example.com"));
console.log(maskEmail("info@test.dev"));
console.log(maskEmail("user@domain.org"));
// apple.pie@example.com
// a********@example.com
// a*******e@example.com ?????????????
// freecodecamp@example.com
// f***********@example.com
// info@test.dev
// i***@test.dev
// user@domain.org
// u***@domain.org
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.5.2 Safari/605.1.15
Challenge Information:
Build an Email Masker - Build an Email Masker