We don't name function parameters in the function declaration. Instead we have an implied index of arguments: `$1, $2, $3,...`. When the function is called, the first value after the function name becomes `$1` by default, then the subsequent arguments.
We can access all the arguments passed to a function using the `$@` syntax we encountered before when [passing arguments to scripts](/Programming_Languages/Shell/Passing_arguments_to_scripts.md). (Here a function is a kind of script in miniature so the process is the same.)
```sh
function numberThings() {
i=1
for f in "$@"; do
echo $i: "$f"
(( i++ ))
done
}
```
## Local variables
```sh
var1="I'm variable 1"
function myfunction() {
var2="I'm variable 2"
local var3="I'm variable 3"
}
myfunction
echo $var1
echo $var2
echo $var3
# I'm variable 1
# I'm variable 2
```
> The convention is to put functions at the top of the script, after the shebang and after the global variables