If you're seeing this message, it means we're having trouble loading external resources for Khan Academy.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Functions

1 project
1 article
3 challenges
5 talkthroughs
Make your code more re-usable by grouping it into functions, and then make those functions accept parameters and return values.

Functions

Pamela explains how you can write your own custom functions to group your code and make it more reusable.

Function Parameters

Pamela shows how you can pass parameters into custom functions, so that they can behave differently each time you call them.

Function Return Values

Pamela explains how to return values from functions, especially useful in doing calculations.

Special ProcessingJS Functions

Pamela reviews the special functions we use for drawing and interaction, like draw(), mouseClicked(), mousePressed(), and others.

Local and Global Variables

Pamela explains the difference between "local" and "global" variables, a tricky concept in programming.

Project: Fish Tank

<p> This program draws a single fish. Poor lonely fish! For this project, you'll use functions to accompany him with more fish of all different shapes and colors. </p> <ol class="styled-list"> <li>Create a custom function (like ...