<script>
const organisationGoogle = {
name: 'Google',
info: {
employees: ['Vlad', 'Olga'],
partners: ['Microsoft', 'Facebook', 'Xing']
}
};
const organisationCompany = {
info: {
employees: ['Olga', 'Vlad'],
partners: ['Xing']
}
};
const getInfo = organisation => {
const { name, info: { partners } } = organisation
return { name: name || `UNKNOWN`, partners: partners.slice(0, 2) }
}
const getOrganisationInfo = ({ name, info: { partners } }) => ({ name: name || `UNKNOWN`, partners: partners.slice(0, 2) })
console.log(getOrganisationInfo(organisationGoogle))
console.log(getOrganisationInfo(organisationCompany))
</script>