0

I am struggling to restructure output which gives me an array such as

   (2) [12.8494951, 77.6587404]
   (2) [12.8499, 77.6536] 

and I want to turn it into a multidimensional array that looks like this

   [[12.8494951,77.6587404],[12.8499, 77.6536]]

Thank you in advance.

5
  • 1
    What's the input of the function? I see two arrays, not one Commented Apr 26, 2018 at 9:28
  • 1
    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking Commented Apr 26, 2018 at 9:28
  • This is not a two dimensional array. This is an array that contains arrays Commented Apr 26, 2018 at 9:29
  • 1
    JS doesn't has md arrays only jugged Commented Apr 26, 2018 at 9:30
  • Please share the code that creates such output. Commented Apr 26, 2018 at 9:32

2 Answers 2

2

Just push incoming arrays into one array, like this.

const groupIntoTwoDem = (arr1, arr2) => [arr1, arr2];
Sign up to request clarification or add additional context in comments.

Comments

2

You could catch all parameters for a new array with rest parameters ....

const getArray = (...array) => array;

console.log(getArray([12.8494951, 77.6587404], [12.8499, 77.6536]));

Comments

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.