ixowen
August 11, 2025, 8:48am
1
Tell us what’s happening:
my first 2 are correct yet my other 2 aren’t showing asterix correctly
Your code so far
const maskEmail = email => {
const str1 = email.slice(0, -(email.length - 1));
const str3 = email.slice(-13);
const str2 = email.slice(1, -13);
let replacementString = "*";
const repeatReplacementString = replacementString.repeat(str2.length);
const replacedPart = str2.replace(str2, repeatReplacementString);
return str1 + replacedPart + str3;
}
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/138.0.0.0 Safari/537.36
Challenge Information:
Build an Email Masker - Build an Email Masker
https://www.freecodecamp.org/learn/full-stack-developer/lab-email-masker/build-an-email-masker
ILM
August 11, 2025, 9:09am
2
why do you think some works and some don’t?
ixowen
August 11, 2025, 9:40am
3
Only my 7, 8 and 9 don’t pass unless im wrong and more of my code is incorrect and it’s
passing due to certain requirements being hit through other code?
ILM
August 11, 2025, 10:05am
4
and what’s the difference between the email addresses used in the passing tests and in the not passing tests?
ixowen
August 11, 2025, 10:06am
5
I have restarted my code and managed to get it to the point where only 9 isn’t passing. I’ll create a new topic.
ILM
August 11, 2025, 10:07am
6
please don’t create a new topic, only one topic per challenge is allowed
1 Like
ixowen
August 11, 2025, 10:08am
7
Tell us what’s happening:
Test 9 isn’t passing. Here is what appears on my console :
ae@example.com
f ***p@example.com
io@test.dev
u r@domain.org
This looks right to me?
Your code so far
let email = "apple.pie@example.com";
const maskEmail = email => {
const atIndex = email.indexOf("@");
const domain = email.slice(atIndex);
const username = email.slice(0, atIndex);
const firstChar = username[0];
const lastChar = username[username.length - 1];
const middle = username
.slice(1, -1)
.replace(/[a-zA-Z.]/g, "*");
return firstChar + middle + lastChar + domain;
}
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/138.0.0.0 Safari/537.36
Challenge Information:
Build an Email Masker - Build an Email Masker
https://www.freecodecamp.org/learn/full-stack-developer/lab-email-masker/build-an-email-masker
ixowen
August 11, 2025, 10:09am
8
there are this amount of asterix in each line :
ILM
August 11, 2025, 10:11am
9
what happens if there is a mail like email+newsletter@gmail.com, does your app manage to mask it all?
ILM
August 11, 2025, 10:13am
11
that seems something you need to fix
what about if there are numbers?
ixowen
August 11, 2025, 10:21am
12
I have passed the code. Just so I understand this more, you have to put in each character that you are wanting to mask when using replace() and you would have to input whatever special characters that are available to use in the input field?
ILM
August 11, 2025, 1:25pm
13
there are various ways in which this can be some, there are some of the ways that don’t include specifying the characters to mask, your way of solving it requires to specify the characters