Map nested array with JavaScript

Map nested array with JavaScript

I'm trying to map a nested array using .map(), so I could display and pinpoint all London underground locations in a map.

I'm trying to map a nested array using .map(), so I could display and pinpoint all London underground locations in a map.

this.undergroundGeoJson = [
        {
            'type': 'FeatureCollection',

        'crs': { 'type': 'name', 'properties': { 'name': 
        'urn:ogc:def:crs:OGC:1.3:CRS84' } },

        'features': [
            {
                'type': 'Feature',
                'geometry': {
                    'type': 'Point',
                    'coordinates': [-0.278126, 51.5025]
                },
                'properties': {
                    'name': 'Acton Town'
                }
            },
            {
                'type': 'Feature',
                'geometry': {
                    'type': 'Point',
                    'coordinates': [-0.263033174, 51.50883531]
                },
                'properties': {
                    'name': 'Acton Central'
                }
            },
            {
                'type': 'Feature',
                'geometry': {
                    'type': 'Point',
                    'coordinates': [-0.262879534, 51.50856013]
                },
                'properties': {
                    'name': 'Acton Central'
                }
            }
       }
   ]

I need the coordinates array elements down in the geometry obj.

this is my code so far...

@computed
    get undergroundLatLongs() {
    return this.undergroundGeoJson.map((u) =>
    [u.features.geometry.coordinates[0], 
    u.features.geometry.coordinates[1]]);
}

and this is the error log...

Uncaught TypeError: Cannot read property 'coordinates' of undefined

any help welcomed.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Clone an Array in JavaScript?

In this JavaScript tutorial, you'll learn how to clone an array in JavaScript. Because arrays in JS are reference values, so when you try to copy it using the = it will only copy the reference to the original array and not the value of the array.

JavaScript Array.flatMap()

JavaScript Array.flatMap(): Use flatMap to map over an array and flatten the result array in one go! Now lets up the game and introduce "flatMap". It combines the steps of first mapping over the array with `map()` & then calling `flat()`. Instead of calling 2 methods, just use `flatMap()` 👍