Created
February 1, 2022 03:37
-
-
Save cacheflow/a685f1ef412e7e759aecb3f97508572e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const emailAddresses = [ | |
'[email protected]', | |
'[email protected]', | |
'[email protected]', | |
'[email protected]', | |
] | |
const isNullOrUndefined = (data) => data === null || data === undefined; | |
const getEmailServiceProvider = (email) => { | |
if (isNullOrUndefined(email) || email.length === 0) { | |
return email; | |
} | |
const beginningOfEmailProvider = email.indexOf('@') + 1; | |
const endOfEmailProvider = email.lastIndexOf('.'); | |
return email.slice(beginningOfEmailProvider, endOfEmailProvider); | |
} | |
const getEmailServiceProviders = (emailAddresses = []) => { | |
if (isNullOrUndefined(emailAddresses)) { | |
return null; | |
} | |
return emailAddresses.map(emailAddress => getEmailServiceProvider(emailAddress)); | |
} | |
console.log(getEmailServiceProviders(emailAddresses)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment