Challenge: Create and Structure an Object
Task
Create a JavaScript object called informationCard
representing basic personal information. Inside this object, include a nested object with contact details, such as a home address and phone number. The object should have the following structure:
Information card (outer object):
- First Name (e.g.,
"Alice"
); - Last Name (e.g.,
"Smith"
); - Age (e.g.,
25
); - Contact Details (nested object).
Contact Details (nested object):
- Home Address (e.g.,
"123 Main St, Apt 4B"
); - Phone Number (e.g.,
"555-123-4567"
).
Note
In this challenge, nothing will be output in the console after clicking 'Run Code' as we don't
console.log()
anything.
123456789const informationCard = { firstName: ___, lastName: ___, ___: ___, contactDetails: { homeAddress: ___, ___: ___, }, };
- Use an object literal to define the outer object.
- Inside the outer object, create a property calledΒ
contactDetails
Β and assign it a nested object. - Inside the nested object, add the necessary properties.
- You can fill in any data.
123456789const informationCard = { firstName: "Alice", lastName: "Smith", age: 25, contactDetails: { homeAddress: "123 Main St, Apt 4B", phoneNumber: "555-123-4567", }, };
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Ask me questions about this topic
Summarize this chapter
Show real-world examples
Awesome!
Completion rate improved to 2.27
Challenge: Create and Structure an Object
Swipe to show menu
Task
Create a JavaScript object called informationCard
representing basic personal information. Inside this object, include a nested object with contact details, such as a home address and phone number. The object should have the following structure:
Information card (outer object):
- First Name (e.g.,
"Alice"
); - Last Name (e.g.,
"Smith"
); - Age (e.g.,
25
); - Contact Details (nested object).
Contact Details (nested object):
- Home Address (e.g.,
"123 Main St, Apt 4B"
); - Phone Number (e.g.,
"555-123-4567"
).
Note
In this challenge, nothing will be output in the console after clicking 'Run Code' as we don't
console.log()
anything.
123456789const informationCard = { firstName: ___, lastName: ___, ___: ___, contactDetails: { homeAddress: ___, ___: ___, }, };
- Use an object literal to define the outer object.
- Inside the outer object, create a property calledΒ
contactDetails
Β and assign it a nested object. - Inside the nested object, add the necessary properties.
- You can fill in any data.
123456789const informationCard = { firstName: "Alice", lastName: "Smith", age: 25, contactDetails: { homeAddress: "123 Main St, Apt 4B", phoneNumber: "555-123-4567", }, };
Thanks for your feedback!