Build an Email Masker - Build an Email Masker

Tell us what’s happening:

it keeps logging out undefined and i am not sure of what to do

Your code so far

function maskEmail(email) {
  let first = email.slice(0, 1);
  let last = email.slice(domain - 1, domain);
  let mid = email.indexof("@");
  let domain = email.slice(mid);
  let stars = "*".repeat(domain - 2);

  return first + stars + last + domain;
}

let email = "joe36@gmail.com";
console.log(email.maskEmail);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:156.0) Gecko/20100101 Firefox/156.0

Challenge Information:

Build an Email Masker - Build an Email Masker

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-email-masker/66b205e6eacba4c4e54ea434.md at main · freeCodeCamp/freeCodeCamp · GitHub

Could you explain what these lines are supposed to do?

The email variable is a sample data meant to test the function and the second line in there is supposed to log the end product of the email being passed through the function.

Does email.maskEmail pass the email variable to the function?

No it does not. Let me revise and make a few touches

I thought changing it to this would produce the intended result but it didn’t

let email = "joe36@gmail.com";
console.log(maskEmail(email));

What does it produce instead?

ReferenceError: can't access lexical declaration 'domain' before initialization

I think i only declared the domain variable later but prior to that i had already tried using it in the upper lines of the code

Thank you very much. I have been able to complete it. I think the main roadblock was that I used variables without paying attention to their datatypes.