Build an Email Masker - Build an Email Masker

my maskEmail function return true result but it not passed

function maskEmail(email){

let findtheadd = email.indexOf("@");

let r = email.slice(findtheadd-1);

let charat=email.charAt(0);

let domain = email.slice(1, findtheadd);

let maskL = domain.length;

let mask = "*";

let repeating = mask.repeat(maskL);

let replaced = domain.replace(domain, repeating);

return charat+replaced+r;

}

let email="apple.pie@example.com";

console.log(maskEmail(email));

email="freecodecamp@example.com";

console.log(maskEmail(email));

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Get Help > Ask for Help button located on the challenge.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

I’ve edited your code for readability. 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 (').

The first failed test is:

  1. maskEmail("apple.pie@example.com") should return "a*******e@example.com" .

So let’s confront your output with the expected one

  actual:   a*******e@example.com
expected:   a********e@example.com

the email after being masked has a different length, that should not happen

thanks alot i got it :pray: