Program Flow: Functions

Learn how to manipulate your program to reusable code and modules using functions.

Now that you have an understanding of the basic data types and operations, we should try to make our programs a little more interesting. We will do this by manipulating the way in which the JavaScript program executes. One way we can accomplish this is through the use of functions.

Functions

Functions allow us to repeat tasks that involve a similar sequence of steps. You’ve already seen the console.log() function, which allows us to predictably log some output to the console.

Let’s look at an example of a function definition that finds the sum of two numbers:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy