function getEligibleEmailForwardingDomain( selectedDomainName, domains = [] ) {
	const eligibleDomains = getEmailForwardingSupportedDomains( domains );
	let selectedDomain;
	if ( selectedDomainName ) {
		selectedDomain = eligibleDomains.reduce( function( selected, domain ) {
			return domain.name === selectedDomainName ? domain.name : selected;
		}, '' );
	}
	return selectedDomain || ( eligibleDomains.length && eligibleDomains[ 0 ].name ) || '';
}
function getEligibleEmailForwardingDomain( selectedDomainName, domains = [] ) {
	const eligibleDomains = getEmailForwardingSupportedDomains( domains );
	let selectedDomain;
	if ( selectedDomainName ) {
		selectedDomain = eligibleDomains.reduce( function( selected, domain ) {
			return domain.name === selectedDomainName ? domain.name : selected;
		}, '' );
	}
	return selectedDomain || ( eligibleDomains.length && eligibleDomains[ 0 ].name ) || '';
}
function getEligibleEmailForwardingDomain ( selectedDomainName , domains = [ ] ) { const eligibleDomains = getEmailForwardingSupportedDomains ( domains ) ; let selectedDomain ; if ( selectedDomainName ) { selectedDomain = eligibleDomains . reduce ( function ( selected , domain ) { return domain . name === selectedDomainName ? domain . name : selected ; } , '' ) ; } return selectedDomain || ( eligibleDomains . length && eligibleDomains [ 0 ] . name ) || '' ; }
Retrieves the first domain that is eligible for Email Forwarding either from the current selected site or the list of domains.

@param {String} selectedDomainName - domain name for the site currently selected by the user
@param {Array} domains - list of domain objects
@returns {String} - Eligible domain name
Retrieves the first domain that is eligible for Email Forwarding either from the current selected site or the list of domains .