my solution work but the test won’t pass it
here’s my code:
function maskEmail(email){
let hi = email.slice(1, -13);
let hi1 = "*";
let repeated = hi1.repeat(hi.length);
let replaced = email.replace(hi, repeated);
return replaced;
}
let email = "apple.pie@example.com";
console.log(maskEmail(email));
email = "freecodecamp@example.com";
console.log(maskEmail(email));
Hi there and welcome to our community!
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
1 Like
This line is problematic:
What would happen if you assigned apple.pie@freecodecamp.com
to your email
variable for instance?