Skip to content

Instantly share code, notes, and snippets.

@EhsanHadid
Created February 23, 2023 09:00
Show Gist options
  • Save EhsanHadid/6f9f8a01d532867b43dddacda764f822 to your computer and use it in GitHub Desktop.
Save EhsanHadid/6f9f8a01d532867b43dddacda764f822 to your computer and use it in GitHub Desktop.
phone util
export const convertPhoneToEmail = (phone: string) => {
// replacing special characters( +,-, (, ), and #. ) to alphabet chars
console.log(phone);
const cleanedPhone = phone
.replace("(", "A")
.replace(")", "B")
.replace(",", "C")
.replace("#", "D")
.replace(" ", "E");
const email = `${cleanedPhone}@yourdomain.com`;
return email;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment