Skip to main content
What are Functions?

Learn about functions, a sequence of commands that can be reused together later in a program.

Jon Mattingly avatar
Written by Jon Mattingly
Updated this week

What are Functions?

In programming, we often reuse code to perform repeated actions or build more complex tasks. Functions allow us to teach the computer a task once and easily reuse the code whenever needed.

Functions in Kodable Basics

Students will practice identifying patterns of commands that repeat in the mazes. If they notice the same pattern being used multiple times, they can create a function to store those commands and reuse them as needed.

In the example below, the function represents the code sequence "right, down, right."

Functions in Kodable Creator

In Kodable Creator, students can modify functions to ensure the game runs smoothly by adjusting elements like game sounds, keyboard controls, and animations.

For example, the image below is from the game "High Flyer," where students can see and edit the functions on the left to control the plane’s behavior.

DRY

Programmers often say; Don’t Repeat Yourself. You can think of this as an acronym to help you understand the purpose of functions: keep your code DRY!

Real-Life Example

We are always learning and building on what we know, like combining simple actions to create more complex ones—similar to how functions work.

In sports, for example, dribbling a soccer ball combines running and kicking into a single, named action. In the classroom, "Criss Cross Applesauce" merges sitting and crossing legs into one memorable term. Once students learn it, we don’t need to explain it every time—they know exactly what to do.

Criss Cross Applesauce Function:

Did this answer your question?