Pin 13 LED will not blink unless serial monitor is active

I have this series of for loops turning LEDs to HIGH and LOW in succession.

However, pin 13 will only go HIGH or LOW if I start the serial monitor. Otherwise is just goes dark. I am confused as to the cause of this problem.

Here is my code:

int ledPins [] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; // define led array
int numberofPins = 11; 
int val = 0;
int potPin = 1;
int sensorVal = 0;

void setup (){
  Serial.begin(9600); // setup serial communication
  for (int i = 0; i < numberofPins; i++){ 
    pinMode (ledPins[i], OUTPUT);
  }    
    
}

void loop (){
  
  sensorVal = analogRead(potPin);    
  val = map(sensorVal, 0, 1024, 10, 100);
  Serial.print(val);             
  
  for (int i = 0; i <= numberofPins; i++){
    digitalWrite(ledPins[i], HIGH);
    delay(val);
    digitalWrite(ledPins[i], LOW);
    delay(val);
    Serial.print("the value of i is: ");
    Serial.println(i);  
}
  
  Serial.println(""); 
  Serial.println(""); 
 
  for (int i = numberofPins; i >= 0; i--){
    digitalWrite(ledPins[i], HIGH);
    delay(val);
    digitalWrite(ledPins[i], LOW);
    delay(val);
  }
}

Any help is greatly appreciated. Thanks in advance for any help received!

Numberofpins needs to be 12. Better still make it sizeof(LedPins)/sizeof(int). You should the change the loop indices to be less than numberofpins as array indices go from 0 to the size of the array less 1.