Start by tracing one small function

Why this matters

When AI writes code for your website, the first useful skill is not writing more code — it is reading a tiny piece and explaining what it does. If you can trace one function with real inputs, you can catch simple mistakes early, ask better follow-up questions, and avoid treating generated code like magic.

Read what goes in and what comes out

Assume for this primer that inputs are finite numbers from 0 to 100. That keeps us focused on reading logic, not input validation.

Look at this function:

function double(score) {
  return score * 2;
}

A function takes an input, does something, and returns a value. To trace it, plug in a real input and follow the steps.

  • Input 10 → compute 10 * 2 → returns 20
  • Input 7 → compute 7 * 2 → returns 14

Don’t start with jargon. Start with: “If I put in 10, what comes back?”

What does double(12) return?

The function returns the result of score * 2, so 12 becomes 24. The choice that keeps the input unchanged is a common first guess when someone notices the parameter but not the return expression. The choice with 14 treats the function like it is adding instead of multiplying. The true answer is tempting if you associate functions with yes/no checks, but this function returns a number, not a boolean.

Like this? Learn anything you want — for free. Sign Up Free