Question: I have around 20 objects like this one below,

```
{ 
       isReadOnly: false
       isRequired: false
       isResettable: false
       name: "test1"
},
{ 
       isReadOnly: false
       isRequired: false
       isResettable: false
       name: "test2"
}

```

I need to merge them into new 10 object, where

0, 1 -> 0 {0: data0, 1: data1}

2, 3 -> 1 {0: data2, 1: data3}

4, 5 -> 2 {0: data4, 1: data5}

x
x

18, 19 -> 9 {0, data18, 1: data19}

20 -> {0: data20, 1: null (or do not exist)}

How can I do it?

Answer: 
```js
const arr = [...Array(20).keys()].map((_, index) => ({ 
       isReadOnly: false,
       isRequired: false,
       isResettable: false,
       name: index
}));

let combinedArr = [];

for(let i = 0; i < arr.length; i+=2){
    combinedArr.push({0: arr[i], 1: arr[i + 1]})
}

console.log(combinedArr);
```
If you have array of objects like [{data0}, {data1}, {data3},...,{data19}]
and you want to make array with 10 object then you can acieve this like:

```
let oldArr = [{data0}, {data1}, {data3},...,{data19}]
let newArr = []
for (let i=0; i < oldArr.length; i=i+2) {
  let obj = {0: oldArr[i], 1: oldArr[i+1]}
  newArr.push(obj);
}

```