Question: I have an array e.g `[0,1,2,3,4,5]` the length will always be even.

How do I select and pair starting from the leftmost and rightmost elements all the way to the center position?

In the above array it should result `[[0,5],[1,4],[2,3]]`

I have tried this so far... [here](https://flems.io/#0=N4IgZglgNgpgziAXAbVAOwIYFsZJAOgCsEAaEAYwHs0AXGWvKtOGgAgwCcPWBeV5AAwkAjCQBMJAMwkALCQCsAXQA6aVUxasO8AK5Q2fZCrQa2AB0pw4EAEawAshhrkAFvF7su+WGgDmNF1YAelYxVVUwSm4AClg2AA8PAQBuVkSAHlYLK1sHJ1d4VPiAamKASlZgVVYtXX18Mx04F2jkTg5keMUSTw7273p-QIBaNNZR4UVFMtUAX3CTajhKWG9KX2jtOD0aMpAyOBhYchoIJbxJRHkQWcVZoA)

```
const arr = [0,1,2,3,4,5]

const result = []
const possibleMatches = arr.length / 2

for (let x = 0; x < possibleMatches; x++) {
  result.push([arr[x], arr[arr.length - x - 1]])
}

console.log(result)
//[ [ 0, 5 ], [ 1, 4 ], [ 2, 3 ] ]

```

However, I think they must be better approach than for loop? like using one line arrow function e.t.c?

Answer: 
You can split the array in half (with [`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)), then [map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) over the array and use the same logic as you did in your `for` loop to get the item on the "right" side:

```js
const arr = [0, 1, 2, 3, 4, 5]

const result = arr.splice(0, arr.length / 2).map((e, i) => [e, arr[arr.length - i - 1]])

console.log(result)
```
You can use `Array.from()` to create an array with half the size of the original, and take the values from the start and end of the original array:

```js
const arr = [0,1,2,3,4,5]

const result = Array.from(
  { length: Math.ceil(arr.length / 2) },
  (_, i) => [arr[i], arr[arr.length - 1 - i]]
)

console.log(result)
```

You can use [`Array.at()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at) (if supported) to reduce the need for `length` calculations:

```js
const arr = [0,1,2,3,4,5]

const result = Array.from(
  { length: Math.ceil(arr.length / 2) },
  (_, i) => [arr.at(i), arr.at(-i-1)]
)

console.log(result)
```