Question
Given an array of users, each represented by an object with the following properties: { name: 'John Doe', age: 35, email: 'john@doe.com', address: { city:
Given an array of users, each represented by an object with the following properties:
{
name: 'John Doe',
age: 35,
email: 'john@doe.com',
address: {
city: 'New York',
state: 'NY'
}
}
Use the forEach method to print the name and email of each user.
Use the map method to create an array of just the names of each user.
Use the optional chaining operator (?.) to safely access the state of each user's address.
Use the rest operator to collect all the remaining properties of each user into a new object.
Use destructuring to extract the name and email of each user into separate variables
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started