All of the functions you have encountered so far in this chapter have been examples of
global functions, which are defined at a global scope. You can also define functions inside
the bodies of other functions, known as nested functions.
Nested functions are hidden from the outside world by default, but can still be called and
used by their enclosing function. An enclosing function can also return one of its nested
functions to allow the nested function to be used in another scope.
You can rewrite the chooseStepFunction example above to use and return nested functions: