I have an array and a counter, which is matched with the array.

What I need is a sequence with the following attributes: When the counter reaches x6, the first 5 items should be set false. When the counter reaches x11, the first 10 items should be set false. So then only 5 items are set to true at once in sequences.

//in .ts for reference
//Counter, which is matched with the array - they are then saved:
this.counter+=1;
var xNum="x"+this.counter;
this.x[xNum] = true;

//Array of items to infinite
public x : any = ["x0", "x1", "x2", "x3", "x4", "x5", "x6",
  "x7", "x8", "x9", "x10", "x11", "x12",
  "x13", "x14", "x15", "x16", "x17", "x18"...]

1 Answers

0
Truntle On Best Solutions

maybe something like this:

if(counter >= 5 && counter % 5 === 0){
  for(let i = this.counter - 5; i < counter; i++){
    const xNum = "x"+this.counter;
    this.x[xNum] = false;
  }
}