Merge every to 2 row in loop to one
Solution 1:
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);
Solution 2:
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);
}