lundi 19 juillet 2021

Iterate over uneven array

So I have a dataset of 16 items, I want to loop through them every 5 items after the first set of 6 so the columns are 6 5 5.

Initially I tried something like this, but then I remembered I had that one orphaned item.

if(thisI <= 6) {
  y = prevtitle.position[0];
} elseif(thisI % 5 == 0) {
  y = prevtitle.position[0] + w + (p *3);
} else {
  y = prevtitle.position[0];
}

Not sure if there is a simple way to do the first 6 and then the next ones in five without a bunch of nested if statements.

Aucun commentaire:

Enregistrer un commentaire