Introduction to JavaScript Functions

Maintainability

When writing functions, we should write them to do one thing and do that thing well. A philosophy also known as the Linux philosophy.

Small specific functions allow for easy debugging, high flexibility and predictable results. It is very hard to find out where we've made a mistake in a several hundred line function, but far easier if said function is split into smaller functions.

const buildRocket = () => {
rocketScience()
engineering()
qualityChecking()
}

In the above example function building a rocket has been split into three sub tasks. If the function returns something unexpected we can easily detect which of the sub-tasks are responsible.