Build an Email Masker - Build an Email Masker

Tell us what’s happening:

Explain why my code is not being tested, although everything seems to be correct.

function maskEmail(email) {
const dog = email.indexOf(‘@’);
const name = email.slice(0, dog);
const name1 = name.slice(1, -1);
const star = ‘*’
const dis = name1.replace(name1, star.repeat(name1.length));
const domen = email.slice(dog);
const eee = "${name.at(0)}${dis}${name.at(-1)}${domen}";
return eee;

}

let email = ‘shadowcancer9@gmail.com’;

console.log(maskEmail(“u**r@domain.org”));

Your code so far

function maskEmail(email) {
  const dog = email.indexOf('@');
  const name = email.slice(0, dog);
  const name1 = name.slice(1, -1);
  const star = '*'
  const dis = name1.replace(name1, star.repeat(name1.length));
  const domen = email.slice(dog);
  const eee = `"${name.at(0)}${dis}${name.at(-1)}${domen}"`;
  return eee;
  
}

let email = 'shadowcancer9@gmail.com';

console.log(maskEmail("u**r@domain.org"));

Your browser information:

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

Challenge Information:

Build an Email Masker - Build an Email Masker

Hi. I ran your code and tests 5 to 10 are not passing. You still have some further work to do on your code.

Is the test button not working for you?

Using backticks in a template literal makes the result a string so the double quotes are unnecessary.

That said, please get into the habit of giving your variables meaningful names. Your future self and other developers on your team will thank you when they read your code.