Issue with expecting }, found 'else'

here is a comparison! If mode == 1 it uses the old way, if mode == 0 it uses the shorter way

int mode = 1;
void draw() {
  if (mode == 0) {
    
    if (mouseX < width/2 && mouseY < height/2) background(255, 0, 0); 
    else if (mouseX > width/2 && mouseY < height/2) background(0, 0, 255); 
    else if (mouseX < width/2 && mouseY > height/2) background(0, 255, 0); 
    else if (mouseX > width/2 && mouseY > height/2) background(255, 255, 0);
    
  } else if (mode == 1) {
    
    if (mouseX < width/2 && mouseY < height/2) {
      background(255, 0, 0);
    } else if (mouseX > width/2 && mouseY < height/2) {
      background(0, 0, 255);
    } else if (mouseX < width/2 && mouseY > height/2) {
      background(0, 255, 0);
    } else if (mouseX > width/2 && mouseY > height/2) {
      background(255, 255, 0);
    }
    
  }
}

1 Like