const user = {
profile: {
name: "Marcus",
address: {
city: "Berlin",
zip: "10115"
}
},
getSubscription: () => ({
plan: "pro",
features: ["analytics", "exports"]
})
};
const city = user?.profile?.address?.city;
const country = user?.profile?.address?.country?.toUpperCase();
const firstFeature = user?.getSubscription?.()?.features?.[0];
const adminRole = user?.roles?.[0]?.name ?? "guest";
console.log(city, country, firstFeature, adminRole); Post #3366
2.64K
CHALLENGE
- 🔥 4
- 👍 3
- ❤ 2
- 🤩 2