One of the most important ideas in software development is: keep it simple.
The problem is, every developer believes all code they write is simple & beautiful.
... I'm going to avoid wading into the tarpit of defining "Simple Code."
Instead I'll show 2 'rules' which have helped me write more testable & adaptable code.
1. Restrict functions to single-purpose.
2. Restrict functions to single-argument (or 2 for (err, value) style).
This can be an array or object with many dimensions.
You may be wondering how single-purpose functions ever amount to anything useful, well, let me introduce you to my friend, Higher Order Functions/Components. You may know this by other names, icluding "Controller."
========
Example "Higher Order Functions" to do multiple math steps/functions.
Using Pure ES2016 - no "frameworks" - just a tape test.