Introduction
Local variables help keep data inside a function so it doesn't affect the rest of the script.
When you want to use a variable only inside a function without changing variables outside.
When writing functions that run multiple times and need fresh variables each time.
When avoiding accidental changes to variables used elsewhere in the script.