Another advantage to using functions is that when someone else writes a function for you, you don't need to understand how the function works. As long as you know what the function does you can use it without worrying about how it works.
In this tutorial series we looked at how to separate out code into a function and call that function instead of having the code appear in multiple places in our page. This allows us to write the code to perform a particular process once and use it from as many places as we need to without duplicating the code. When we need to change that code there will only one place that needs to be changed in order for that same change to apply everywhere that the function is called.
This article written by Stephen Chapman, Felgall Pty Ltd.