Objects can contain other objects. Here we've nested two object literals within the tournament object:
const tournament = {
referee: {
name: "Sally",
age: 25,
},
prize: {
units: "dollars",
value: 100,
},
};
We can access nested properties the same way by chaining: tournament.referee.name
console.log(tournament.referee.name); // Sally
console.log(tournament.prize.value); // 100
In most systems, "entities" are stored as objects. For example, "campaigns", "messages", and "users" might all be different "entities" within the Textio system.
We store text campaigns as nested JavaScript objects:
{
name: 'Jurassic Campaign',
messageCount: 100,
creator: {
firstName: 'Ian',
lastName: 'Malcolm',
createdAt: '2023-10-01T09:00:00+00:00'
}
}
Finish the getCampaignCreator function, which takes a campaign object and returns the creator's first name.