All Foundations
Stage 2 · Understand the Build Beginner Last reviewed June 2026

Variables & Functions in Plain English

Master these two ideas and most code stops looking like noise and starts looking like instructions.

Almost every program ever written is built from two simple ideas. If you understand a variable and a function, you can read the shape of most code — and tell an AI exactly what you want it to change.

Where you are: 1 · Talk to the AI 2 · Understand the build → you are here 3 · Check & secure 4 · Ship it
A variable is a labelled box; a function is a recipe with inputs and a result
Two ideas behind almost every line of code

A Variable Is a Labelled Box

A variable is a named box that holds one value. You put something in, give the box a name, and read it back later. price = 9.99 means "the box called price holds 9.99." Change it whenever you like; the name stays the same.

That's it. When you see a word followed by = and a value, you're looking at a variable being filled. The name is chosen by a human to be readable — which is why good names make code easier to follow.

A Function Is a Recipe

A function is a reusable set of steps. It takes ingredients (inputs), does something, and hands back a result. addTax(price) takes a price, applies tax, and returns the new total. Call it once or a thousand times — same recipe, fresh result each time.

Functions are how code avoids repeating itself. Write the recipe once, reuse it everywhere. When something behaves the same way in many places, it's almost always a function doing the work.

THE ONE-LINE VERSION

A variable stores a value. A function takes inputs and returns a result. Most code is just boxes and recipes working together.

Why This Helps You Vibe Code

When you can name the pieces, your instructions get sharper. Instead of "change the price thing," you can say "the price variable should default to 0" or "the addTax function should round to two decimals." Precise nouns make the AI's job — and yours — far easier. (More on that in How to Brief an AI.)

Q: Do variables and functions work the same in every language?

A: The syntax differs, but the concept is universal. Once you get "box" and "recipe," you can read the gist of almost any language.

Q: What makes a good variable name?

A: One that says what's inside without a comment — totalPrice beats tp. Clear names are the cheapest way to make code (and AI output) easier to work with.

A function takes an input, applies its recipe, and returns a result
A function is a recipe machine

The Prompt Template

Precise nouns get precise code:

Create a function called <name> that takes <inputs>
and returns <result>.
Use clear variable names I can read without comments.

Next Steps

Values often travel between apps as labelled data — read What Is JSON next, then keep your keys safe with Environment Variables & Secrets.

Related foundations

Put it into practice

The Micro-Tool Empire

Open the Blueprint