How to make up the number of arrays with empty arrays

 test = 
   [
        ["qwe","1"],
        ["ewq","2"],
        ["aaa","4"],
    ]


I want to keep the number of arrays at four, fill in the empty array if there is a gap, and fill in according to the numbers in the array, but where to fill in

finish filling like this

 test = 
       [
            ["qwe","1"],
            ["ewq","2"],
            ["",""],
            ["aaa","4"],
        ]
        
        

how do I achieve this requirement?

Jun.18,2022

let test = [
            ["qwe", "1"],
            ["ewq", "2"],
            ["aaa", "4"],
        ]

        function setArr(test) {
            for (let i = 0; i < test.length; iPP) {
                const item = test[i];
                if (i + 1 != item[1]) {
                    test.splice(i, 0, ['', ''])
                }
            }
            return test
        }

        console.log(setArr(test))

test.reduce((acc, cur, i) => {
  while (cur[1] - 1 != i) {
    acc.push(['', '']);
    iPP
  }
  acc.push(cur);
  return acc;
}, [])

the premise defaults that the original array is in sequential order (1, 2, 3.) Arranged

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e486b8-444f1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e486b8-444f1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?