May 2015
Beginner
360 pages
6h 39m
English
Content preview from Coding with JavaScript For Dummies
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
Start your free trial


Chapter 7
Getting Functional
In This Chapter
Writing functions
Documenting functions
Passing parameters
Returning values
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!
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, ...
Don’t forget to visit the website to check out the online exercises relevant to this chapter!