0

Let's say I have 2 individual arrays that consists of lat and long values respectively.

lat = [23,34,25];
long = [11,12,13];

My question is how do i create output of combined lat and long arrays above to :

combined_latlong = [ [23,11] , [32,12], [25,13] ];
1

1 Answer 1

2

You can use map()

const lat = [23, 34, 25];
const long = [11, 12, 13];

const result = lat.map((l, i) => [l, long[i]]);

console.log(result);

Sign up to request clarification or add additional context in comments.

1 Comment

Works like a charm for my application. God bless you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.