How do I use for loops in js to overlay loops on a 3-bit basis?

problem description

for example, I now have the following array var a = [1, 2, 5, 3, 5, 5, 6, 8, 9];
I want to arrange the circular output in the order of 1, 2, 3 / 4, 5, 6 / 7, 8, 9

the environmental background of the problems and what methods you have tried

I try to use for (j = 0; j < data.files [I] .item.length; j + = 2)
but the result is not the same as expected, how can it be realized?

Apr.07,2021


var a = [1, 2, 3, 4, 5, 6, 7, 8, 9];
a.reduce((res, item, index) => {

  if (index % 3 === 0) {
    return res + '/' + item
  }
  return res + ',' + item
})
Menu