Skip to content

Instantly share code, notes, and snippets.

@MVAodhan
Last active July 18, 2022 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MVAodhan/c76ecaaada95c98e7e633f8a237cf793 to your computer and use it in GitHub Desktop.
Save MVAodhan/c76ecaaada95c98e7e633f8a237cf793 to your computer and use it in GitHub Desktop.
const hideEmail = (email) => {
let emailParts = email.split('@');
let letters = [...emailParts[0]];
let lettersCopy = [...letters]
const first = lettersCopy.shift()
const last = lettersCopy.pop()
let blanks = []
for (let letter of lettersCopy) {
blanks.push('*')
}
let joinedBlanks =blanks.join('')
let blankedEmail = `${first}${joinedBlanks}${last}@${emailParts[1]}`;
return blankedEmail
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment