Trouble with Arrays to control LEDs

@mattbolty that is a common problem with beginners and advanced programmers alike: staring at a sketch and not seeing the problem that everyone else spots immediately.

Look at the numbers:

const int LED[4] = {2,3,4,7};
const int button[4] = {6,7,8,9};

Do you see that number 7 is used twice ?

Compare the numbers in the array with your project. In the photo you use other pins than those numbers.

Look at the code in the loop():

  if(digitalRead(button[i])==LOW){
    digitalWrite(LED[i],HIGH);
    delay(10);
  }

Do you notice that the led is turned on, but never turned off when the button is released ?

I hope you understand now what the others are saying.

Don't try to set pins that you don't use and keep it as simple as possible. Just two for-loops to initialize the pins is the most simple I think:

const int ButtonPins[4] = { 2, 3, 4, 5};
const int LedPins[4] = { 10, 11, 12, 13};

void setup() 
{
  // Serial.begin(9600);      // Serial output is not used yet.

  // Set the pins for the buttons
  for( int i=0; i<4; i++)
  {
    pinMode( ButtonPins[i], INPUT_PULLUP);
  }

  // Set the pins for the leds
  for( int i=0; i<4; i++)
  {
    pinMode( LedPins[i], OUTPUT);
  }
}


void loop() 
{
  // check if the buttons are pressed and light up the corresponding LED
  for( int i=0; i<4; i++)
  {
    if( digitalRead( ButtonPins[i]) == LOW)
    {
      digitalWrite( LedPins[i], HIGH);
    }
    else
    {
      digitalWrite( LedPins[i], LOW);
    }
  }

  delay( 10);    // slow down the sketch
}

The sketch in Wokwi simulation: