Originally Posted by jaime82
Thank you! I guess what confuses me slightly is the way in which isAccessAuthorised first has the argument 'enteredPassword' at the beginning of the first function and then in the buttonClicked function picks up the 'pass' variable as its argument instead. I guess I somehow assumed that functions have fixed arguments. I guess that's not the case.
One other thing: once defined, function names are "global" in the sense that they can be referred to anywhere in the script without having to define them again in any way? Whereas this is not the case with variables is it, you cannot reference a variable inside a function if it was "created" in another function?
Functions have fixed argument names, but when the function is called (used) the value stored in this argument will be different each time. This is essentially why functions are so useful.
Yes, functions can be called from anywhere within the page and variables defined within it are not available outside the function. (Well, almost.. but don't worry about that now
Variables can also be created outside of any function and can then be used anywhere in the code. These are global variables
but we try hard to avoid these
[I have to complete this description by saying that functions can contain other functions that would not be accessible outside the main function but, again, this shouldn't be of concern to you at the stage you're at.]