For loop into a function

Why not initialise it in setup?
Actually, why does it have global scope at all?

Please remember to use code tags when posting code.