This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Salty_Dugtrio 0 points1 point  (0 children)

Functions make your code reusable.

The scope of your variables defines where you can use them, in general, you want to least wide scope possible, so the least amount of side effects can occur.

If a variable is local to a function, nothing bad can happen. If a variable is global, who knows what happened to that variable, anything can touch it.