Name Functions Clearly: A function's name should be a verb that describes exactly what it does. This makes your code self-documenting and easier for you (and others) to read.
One Function, One Job: Each function should be responsible for one single task. Splitting the work into smaller functions makes your code more flexible, easier to test, and simpler to debug.
Pass Data In, Return Data Out: A function is most predictable and reusable when it gets all the data it needs from its parameters and sends its result back using the return keyword.
Keep Parameters to a Minimum: Functions with too many parameters can be confusing to use. If you find yourself needing to pass a lot of data, consider grouping it into a single object.