Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I wrote the entire function and tested the variables separately with a console.log, but when I log the function with the email parameter, the console displays an undefined error.

Your code so far

function maskEmail(email) {

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

let preMail = email.slice(0,indexAro)

let maskMail1 = preMail.slice(1,preMail.length-1);

let maskMail2 = maskMail1.replace(maskMail1,"*");

maskMail2 = maskMail2.repeat(maskMail1.length);

let maskMail3 = preMail.replace(maskMail1,maskMail2);

let sufMail = email.slice(indexAro+1);

let final = maskMail3 + "@" + sufMail;

}

let email;

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) 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 @vlad.salomont and welcome to our community!

I would start by addressing this failing test:

  1. You should assign a valid email address to your email variable.

Also, what value does your function return?

thank you, i final return the final var inside the function and assign a valid email to “email” variable .

1 Like