Tell us what’s happening:
even though i am getting the exact results i cannot pass the challenge
Your code so far
function maskEmail(email){
const atIndex = email.indexOf('@');
const firstChar = email[0];
const lastChar = email[atIndex - 1]
const stars = '*'.repeat(atIndex - 1);
const domain = email.slice(atIndex);
return firstChar + stars +lastChar + domain;
}
let email ;
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/143.0.0.0 Safari/537.36 Edg/143.0.0.0
Challenge Information:
Build an Email Masker - Build an Email Masker
dhess
2
Count the asterisks in your results and compare to the result that’s expected.
thanks for the answer , i actually got the right result as it was asked i tried every way i know with the right result and it still didn’t pass
dhess
4
Try logging like this to show actual versus expected results:
let email ;
email = "apple.pie@example.com";
console.log("Actual: ", maskEmail(email));
console.log("Expected: ", "a*******e@example.com");
1 Like
i tried ur way and it’s the same problem
dhess
6
Please post the results you see in the console. Are you copying the expected result from the tests as the "Expected: " value?
dhess
8
That’s not what I asked you to do.
well , maybe i didn’t understand u properly
dhess
11
I’m asking you to log like this so you can see where the issue is in your code. Then you can go to the line of code that handles that and correct it.