Contenido del Curso
JavaScript Data Structures
JavaScript Data Structures
Challenge: Creating 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.
const 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.
const informationCard = { firstName: "Alice", lastName: "Smith", age: 25, contactDetails: { homeAddress: "123 Main St, Apt 4B", phoneNumber: "555-123-4567", }, };
¡Gracias por tus comentarios!