Introduction
Local functions help organize code by putting small helper functions inside bigger ones. This keeps related code together and easier to read.
When you want to break a big function into smaller steps without making those steps visible outside.
When a helper function is only useful inside one main function.
When you want to avoid cluttering the outer scope with functions used only once.
When you want to improve code readability by grouping related logic.
When you want to use variables from the outer function directly inside the helper function.