Function definition (unexpected functionality)

Thank you! Very much appreciate the details.

How should I change the code to use the present value stored in ‘a[2]’ (at the time of declaration of function) vs looking up what will be stored there at the time the function is called?