Build an Email Masker - Build an Email Masker

Tell us what’s happening:

Моя функция выводит правильный результат, но 5-10 пункты лабораторной работы не считаются выполненными. Почему?

Your code so far

function maskEmail (email) {
  let startSymbol = email[0];
  let endPositionLine = email.indexOf("@") - 1;
  let endLine = email.slice(endPositionLine);
  let catLineLength = email.slice(1,endPositionLine).length;
  let newLine = "*".repeat(catLineLength);
  return(`"${startSymbol}${newLine}${endLine}"`);
}

let email = "apple.pie@example.com";
console.log(maskEmail("apple.pie@example.com"));

console.log(maskEmail("freecodecamp@example.com"));

console.log(maskEmail("info@test.dev"));

console.log(maskEmail("user@domain.org"));



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

Hi.

Have a look at user story 4.

Also try string concatenation instead of template literals to see if that works.

I see why you added the quotes inside your template literal, but when the tests say it should return e.g. “a*******e@example.com”, it just means that you should return a string. Try removing the quotes.

1 Like

Thanks, I did a standard derivation without using template literals and was able to complete steps 5-9. But step 10 remains incorrect. What’s wrong?

What is Test #10? Please post your updated code.

Did you look at User Story #4?

Please do not post screenshots. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

function maskEmail (email) {
  let startSymbol = email[0];
  let endPositionLine = email.indexOf("@") - 1;
  let endLine = email.slice(endPositionLine);
  let catLineLength = email.slice(1,endPositionLine).length;
  let newLine = "*".repeat(catLineLength);
  return(startSymbol + newLine + endLine);
}

let email = "apple.pie@example.com";
console.log(maskEmail("apple.pie@example.com"));

console.log(maskEmail("freecodecamp@example.com"));

console.log(maskEmail("info@test.dev"));

console.log(maskEmail("user@domain.org"));

I managed to figure out how to accomplish this task. I added the email variable idea to the beginning of each console.log call, and it worked!

1 Like

Don’t need to put your regular text comments in triple backticks, it actually makes it harder to read.

Only posted code should be formatted as code.

  1. Call the maskEmail function with the email variable and output the result to the console.

Be sure to review the User Stories and ensure they are implemented correctly.