LED sequence changes direction based on number of times the button is pushed

im making a program that will make 10 LED light up after one another if i pushed the button in odd number of times it will go clockwise and in even number it will go to counter clockwise starting from the last led that lit up
problem is when ever the loop for clockwise and counter clockwise is in executed, when i press the button again it doesn't register the button press it has to wait until the loop is finished before reading the button press

int led = 10;
int LED[] = {2, 3, 4, 5, 6, 7, 9, 10, 11, 12}; 
const int buttonPin = 12;  
const int ledPin = 13;         
int buttonState;            
int lastButtonState = LOW;
unsigned long lastDebounceTime = 0;  
unsigned long debounceDelay = 50;
int ledState = HIGH;   
int counter=0;
int pin = 0;

void setup()
{
for(int pin=0; pin<led; pin++)
  {
    pinMode(LED[pin],OUTPUT);
    }
    pinMode(buttonPin,INPUT_PULLUP);
    Serial.begin(9600);
     
}


void loop()
{
  int reading = digitalRead(buttonPin);
  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        ledState = !ledState;
        counter++;
      }
    }
  }
  // set the LED:
  digitalWrite(ledPin, ledState);
  Serial.println(counter);
  lastButtonState = reading;

  if((counter%2)==0)
  {
    for(int thispin = 0; thispin<led;thispin++) //loop for the counter clockwise
    {
      digitalWrite(LED[thispin],HIGH);
      delay(300);
      digitalWrite(LED[thispin],LOW);
    }
  }
  if((counter%2)!=0)
  {
    for(int thispin =led-1; thispin>=0;thispin--) //loop for the counter clockwise
    {
      digitalWrite(LED[thispin],HIGH);
      delay(300);
      digitalWrite(LED[thispin],LOW);
    }
  }
}

_7_segment_button.ino (1.39 KB)

The problem is you are using delay in a loop.

Solution :- look at the state change example in the IDE for counting button presses.
Look at the blink without delay example in the IDE for how to code as a state machine.
Then the least significant bit of the count variable will indicate an odd or even number of pushes.