Function to change led state not working

I wrote simple function to changed led state

void changeLedState(boolean led)
{
led = !led;
}

and pass it in the main loop to change led state once pin read HIGH after switch is pressed

void loop() {

currentState = debounce(lastState);
if (lastState == LOW && currentState == HIGH)
{
changeLedState(ledState); // ledState initialized globally to LOW
}
lastState = currentState;
digitalWrite (ledPin, ledState);
}

I am not sure why the code doesn't work as led does not change state on pressing switch.

I manage to write function that works

void changeLedState()
{
led = !led;
}

void loop() {
// put your main code here, to run repeatedly:
currentState = debounce(lastState);
if (lastState == LOW && currentState == HIGH)
{
changeLedState();
}
lastState = currentState;
digitalWrite (ledPin, ledState);
}

Just curious to know why the function did not work the first time.

The function alters the led variable but you don't seem to use it anywhere in the snippets of programs that you have posted.

Unless you need know the state of the LED for some reason you could just write

digitalWrite(ledPin, !digitalRead(ledPin));

You need to understand the concepts of "passing by value" and "scope".
When called, your function is passed a copy of the value of "ledState" .
Your function uses this local copy, inverts it and exits.
Result is, no change to ledState.

but you don't seem to use it anywhere in the snippets of programs that you have posted.

?

but you don't seem to use it anywhere in the snippets of programs that you have posted.
?

Have you spotted somewhere the value of the led variable is used because I haven't