← the wiki

Function

A named recipe of code you write once and call whenever you need it.

A function wraps a few lines of code, gives them a name, and lets you run them on demand: define double(number) once, call it a thousand times. Functions can take inputs (parameters) and hand back a result (return).

They are the main tool programmers use against complexity: big problems get chopped into small named recipes, each easy to understand, test, and reuse.

The best way to make it stick: watch it run. Start an interactive lesson →