hello my code is not working could anyone help

hello i am new to arduino programming and i was trying to write a program that slowly increases then decreases the brightness of an led.

const int led = 11 ;


void setup()
{
 Serial.begin(9600);
 pinMode(led, OUTPUT);

 int j = 3;
 while(j > 0)
 {
 Serial.print(j);
 Serial.print(", ");
 j--;
 }
 Serial.println("GO...\n");
}

void loop()
{
 static int val = 5;
 static int dir = 1;
 val += 50 * dir ;
 val = a(val, dir) ;
 analogWrite(leds[0], val) ;
 delay (500) ;
 Serial.println(val);
}



int a (int val, int dir)
{
 if ((val == 255) || (val == 0))
 {
 dir = dir * -1 ;

 if (dir < 0)
 {
 Serial.println("Going Up");
 }
 else
 {
 Serial.println("Going Up");
 }
 
 }
 return dir ;
}

this is my code. can anyone show what i am doing wrong. im using an arduino uno

Thanks for posting in code tags.
What do you think this line does?

 analogWrite(leds[0], val) ;

The array 'leds[]' has not even been declared anywhere in your program. The compile error messages probably told you that.

aarg:
The array 'leds[]' has not even been declared anywhere in your program. The compile error messages probably told you that.

i noticed that and changed it later (i also edited the code in the question)but it still didnt work

Good job using code tags with your first post.

i noticed that and changed it

Are you going to post the code so that we can see what you have done?

val = a(val, dir) ;
 analogWrite(leds[0], val) ;
 delay (500) ;
 Serial.println(val);

What is your serial print showing?

The function a(val,dir) concludes with return dir what do you expect the values to be?

int a (int val, int dir)
{
 if ((val == 255) || (val == 0))
 {
 dir = dir * -1 ;

 if (dir < 0)
 {
 Serial.println("Going Up");
 }
 else
 {
 Serial.println("Going Up");
 }
 
 }
 return dir ;
}