Templates for Chubb need updating.
This commit is contained in:
25
Scripts/blank_javascript.js
Normal file
25
Scripts/blank_javascript.js
Normal file
@ -0,0 +1,25 @@
|
||||
function extractEmailDomain(email) {
|
||||
// Check if email is provided and is a string
|
||||
if (!email || typeof email !== 'string') {
|
||||
return 'Please provide a valid email address';
|
||||
}
|
||||
|
||||
// Check if email contains @ symbol
|
||||
if (!email.includes('@')) {
|
||||
return 'Invalid email format';
|
||||
}
|
||||
|
||||
// Split the email at @ and get the domain part
|
||||
const domainPart = email.split('@')[1];
|
||||
|
||||
// Remove .com or any other extension
|
||||
const domain = domainPart.split('.')[0];
|
||||
|
||||
return domain;
|
||||
}
|
||||
|
||||
// Example usage:
|
||||
console.log(extractEmailDomain('user@gmail.com')); // Output: gmail
|
||||
console.log(extractEmailDomain('john.doe@yahoo.com')); // Output: yahoo
|
||||
console.log(extractEmailDomain('contact@company.org')); // Output: company
|
||||
|
||||
Reference in New Issue
Block a user