Note that the function definition must precede the first call to it. This is a funky function. Now, call the function. More complex functions may have arguments passed to them and return exit values to the script for further processing. In contrast to certain other programming languages, shell scripts permit passing only value parameters to functions.
Functions interpret their arguments literally.
It's crude, but it works. A variable declared as local is one that is visible only within the block of code in which it appears. In a shell script, this means the variable has meaning only within its own function. You gotta have rocks in your head to try it. If you want greater range than this, rewrite it in a real programming language.