Project 8-LED get all to HIGH

Hi,i’m at project 8 and when i run the arduino all the leds go to HIGH at the same time,instead of one by one.any ideias on what could be the mistake?Thanks

My code:

const int switchPin=8;
unsigned long previousTime=0;
int switchState=0;
int prevSwitchState=0;
int led=2;
long interval=150000;

void setup(){
for(int x=2;x<8;x++){
pinMode(x,OUTPUT);
}
pinMode(switchPin, INPUT);
}

void loop(){
unsigned long currentTime=millis();
if(currentTime-previousTime>interval){
digitalWrite(led,HIGH);
led++;

if(led==7){
}
}
switchState=digitalRead(switchPin);

if(switchState!=prevSwitchState){
for(int x=2;x<8;x++){
digitalWrite(x,LOW);
}
led=2;
previousTime=currentTime;
}
prevSwitchState=switchState;
}

Hi Meteoros

The problem with your code is that you need to reset the previousTime variable after you compare it:

if(currentTime-previousTime>interval){
 previousTime = currentTime;
 digitalWrite(led,HIGH);
 led++;
}

Hope that helped