Here is an object with arrays that contain objects (similar to JSON you might get back from an API)
const business = {
name: 'Google',
location: 'Venice, Ca',
services: [
{
name: 'Google Voice',
requests: [
{
summary: 'Read my lips',
details: 'Details of of the request...',
},
{
summary: 'Log in with face recoginition',
details: 'Details of of the request...',
},
],
},
{
name: 'Google Maps',
requests: [
{
summary: 'Make it rain',
details: 'Details of of the request...',
},
{
summary: 'Make it shine',
details: 'Details of of the request...',
},
],
},
],
};
To get access to the name of the business - it's business.name -> Google
to get access to services array within bussiness I can do something like:
const services = business.services -> now I have my services array and can map over that:
services.map(service => {
return services.name
}
I will get -> ['Google Voice', 'Google Maps']
But the services has it's own nested array (requests). Now I can get access to that with:
services.requests[0] or [1]
The question is: How do I 'extract out' requests into it's own variable so that I may map over that as well without having to use [0][1] etc...