Build an Email Masker - Build an Email Masker

Tell us what’s happening:

I am stuck on the last last letter one ive tried but i dont know

Your code so far



function maskEmail(email)
{
    let sepDomain = email.indexOf('@')
    let domain = email.slice(sepDomain)
    let firstLetter = email[0]
    let lastLetter =''
    let maskEmail = '*'.repeat(email.length - domain.length -1)
    return firstLetter +lastLetter + maskEmail + domain
}
let email ="apple.pie@example.com"
console.log(maskEmail(email))
console.log(maskEmail("freecodecamp@example.com"))
console.log(maskEmail(maskEmail("info@test.dev")))
console.log(maskEmail(maskEmail("user@domain.org")))


Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:153.0) Gecko/20100101 Firefox/153.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

Hi @verver,

You have the index of “@”, right? You can use that to get the index of the last letter then position the last letter in the right place in your return string.

Happy coding

i realized and did that thank you