I would like to merge two different array of objects to one, as follows:
Array 1:
[ { id: 1,
fullName: '...',
districtName: '...',
cityName: '...',
placeName: '...',
geoLat: '...',
geoLong: '...' },
{ id: 2,
fullName: '...',
districtName: '...',
cityName: '...',
placeName: '...',
geoLat: '...',
geoLong: '...' },
]
Array 2:
[ { a:'...',
b:'...',
c:'...',
},
{ d:'...',
e:'...',
f:'...',
}
]
Array 1 and array 2 have same length. I would like to merge them correspondely, as follows:
[ { id: 1,
fullName: '...',
districtName: '...',
cityName: '...',
placeName: '...',
geoLat: '...',
geoLong: '...',
a:'...',
b: '...',
c: '...' },
{ id: 2,
fullName: '...',
districtName: '...',
cityName: '...',
placeName: '...',
geoLat: '...',
geoLong: '...',
d:'...',
e: '...',
f: '...' },
]
How would I do this? I've thought about using map, but that way I can only iterate through one array. I have to iterate both array and merge them.
Any suggestions are helpful. Thank you