Tell us what’s happening: can I write it in a better way? Or could you plz give some suggestions?
Your code so far
function maskEmail(email){
let len = email.slice(1,email.indexOf("@"));
const length = len.length-1;
email = email.replace(email.slice(1,email.indexOf("@")-1),"*".repeat(length));
return email;
}
let email = "apple.pie@example.com";
console.log(maskEmail(email)) ;
maskEmail("freecodecamp@example.com");
maskEmail("info@test.dev");
maskEmail("user@domain.org");
maskEmail("com.user@example.com");
maskEmail("test.net@netnet.net");
maskEmail("testtest@domain.com");
Lesson URL (copy - paste from your browser’s address bar)