Chapter 7

Getting Functional

In This Chapter

arrow Writing functions

arrow Documenting functions

arrow Passing parameters

arrow Returning values

arrow Organizing programs with functions

“I write as a function. Without it I would fall ill and die. It’s much a part of one as the liver or intestine, and just about as glamorous.”

— Charles Bukowski

Functions help you reduce code repetition by turning frequently used bits of code into reusable parts. In this chapter, you write some functions and use them to make otherwise tedious tasks easy and fun!

ontheweb Don’t forget to visit the website to check out the online exercises relevant to this chapter!

Understanding the Function of Functions

Functions are mini programs within your programs. Functions serve to handle particular tasks within the main program that may be required multiple times by different parts of the program.

If you’ve read any of the preceding chapters, ...

Get Coding with JavaScript For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.