const user = {
profile: {
getName: () => "Marcus",
getAge: () => 30,
},
settings: null,
};
const name = user.profile?.getName?.();
const age = user.profile?.getAge?.();
const theme = user.settings?.getTheme?.() ?? "dark";
const lang = user.address?.getLocale?.() ?? "en-US";
console.log(`${name} | ${age} | ${theme} | ${lang}`);
Post #3035
2.91K
CHALLENGE
- ❤ 6
- 👍 3