Build an Email Masker - Build an Email Masker

Tell us what’s happening:

Je réussis à masqué l’email mais pas d’une façon..,. vérifier mon code svp

Your code so far

function maskEmail(email){
let emailIndex= email.indexOf("@")
let emailSlice= email.slice(1,emailIndex-1)
let emailReplaced=email.replace(emailSlice,"**")
return emailReplaced
}
let email="apple.pie@example.com"
console.log(maskEmail(email))
email="freecodecamp@example.com"
console.log(maskEmail(email))
email="info@test.dev"
console.log(maskEmail(email))
email="user@domain.org"
console.log(maskEmail(email))

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36

Challenge Information:

Build an Email Masker - Build an Email Masker

Should you hard code the number of asterisks? Hardcoding makes your function inflexible because it will always replace the email with only two asterisks regardless of how many letters the email contains.

  1. maskEmail("apple.pie@example.com") should return "a*******e@example.com".

Your function returns a**e@example.com. If there are 9 characters there should be 7 *

Votre fonction renvoie a**e@example.com. S’il y a 9 caractères, il devrait y avoir 7 astérisques (*).

Can you think of how to replace each letter with *?

Comment remplacer chaque lettre par un astérisque ?