switching booleans

i have this code

var ispaused : boolean = false;
function Update () {
    if(Input.GetKeyDown("p")){
        Switch(ispaused);
    }

}

function Switch (bool){
    if(bool == false){
        bool = true;
    }
    else{
        bool = false;
    }
    return bool;
}

the code is supposed to switch the var ispaused, but it does not. Any help on the matter would be very nice.

You can actually remove the function entirely, and use this instead:

if(Input.GetKeyDown("p")){
    isPaused = !isPaused;
}

I'm not that familiar with Javascript, is it passing the Boolean by reference, or value? If it's by value, then you need to say:

ispaused = Switch(ispaused);