// Procedural const getPhoneAreaAndNumber = ({ whatsappPhone, cellPhone, homePhone }) => { if (whatsappPhone && isCellPhone(whatsappPhone)) return { area: getPhoneArea(whatsappPhone), number: getPhoneNumber(whatsappPhone) } if (cellPhone && isCellPhone(cellPhone)) return { area: getPhoneArea(cellPhone), number: getPhoneNumber(cellPhone) } if (homePhone && isCellPhone(homePhone)) return { area: getPhoneArea(homePhone), number: getPhoneNumber(homePhone) } return { area: '', number: '' } } // We can turn the above into this: // Functional const getPhoneAreaAndNumber = ({ whatsappPhone, cellPhone, homePhone }) => pipe( find(isCellPhone), formatters.phone.format, )([whatsappPhone, cellPhone, homePhone]) // Cool, huh‽