November 2022
Beginner
624 pages
13h 39m
English
In this Chapter
Learn how functions help you better organize and group your code
Understand how functions make your code reusable
Discover the importance of function arguments and how to use them
So far, all the code we’ve written really contained no structure. It was just…there:
alert("hello, world!");
There is nothing wrong with having code like this. This is especially true if our code is made up of a single statement. Most of the time, though, that will never be the case. Our code will rarely be this simple when we are using JavaScript in the real world for real-worldly things.
To highlight this, let’s say we want to display the distance something has traveled (see Figure 3.1).
FIGURE 3.1
Distance traveled
If you remember ...
Read now
Unlock full access