Tell us what’s happening:
My output prints the desired results. But for some reason there is something wrong with my code, as if I’m missing something. NOTE: I used the commented code, and it did not pass still.
Your code so far
let email = "apple.pie@example.com";
const maskEmail = (email) => {
const atIndex = email.indexOf("@") -1
const firstChar = email[0]
const domain = email.slice(atIndex)
const maskLength = atIndex
const stars = "*".repeat(maskLength);
return firstChar + stars + domain;
}
console.log(maskEmail(email))
console.log(maskEmail("freecodecamp@example.com"))
console.log(maskEmail("info@test.dev"))
console.log(maskEmail("user@domain.org"))
console.log(maskEmail("user@domain.org"))
// email = "freecodecamp@example.com"
// console.log(maskEmail(email))
// email = "info@test.dev"
// console.log(maskEmail(email))
// email = "user@domain.org"
// console.log(maskEmail(email))
// email = "user@domain.org"
// console.log(maskEmail(email))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Challenge Information:
Build an Email Masker - Build an Email Masker