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

