How to read fast

Lesson 1 The three passes

5 min read · JavaScript · Quiz

headline in 5 seconds, shape in 30, then close attention only where it can hurt

What you'll learn

  • Skim a function in three passes instead of reading it line by line
  • Say what a function does from its name, inputs and return value
  • Know which few lines deserve the close reading

An AI just handed you a 40-line function. Reading it from the top, line by line, is the slowest way to review it and the least likely to find the bug.

The idea

Skim in three passes. Pass 1, the headline (5 seconds): read only the name, the inputs and what comes back, and say what the function does in one sentence. Pass 2, the shape (30 seconds): see the blocks (a loop, a guard, a call to the outside world) and give each one a word. Pass 3, the fine print: read closely only the lines that can hurt: money, time, user input, the network, the disk, anything deleted.

Most lines are plumbing and can't be wrong in an interesting way. The bug is almost always in a few lines, and the first two passes tell you which.

invoiceTotal.js
1function invoiceTotal(items, discountPct) {2  let total = 0;3  for (const item of items) {4    total += item.price * item.qty;5  }6  const discount = total * discountPct / 100;7  return total - discount;8}
  1. Line 1 Pass 1: the name, the inputs and the output. "The total of an invoice after a percentage discount."
  2. Line 3 Pass 2: a loop that adds up price times quantity. Name it: sum.
  3. Line 6 Pass 2: apply the discount. Name it: discount.
  4. Line 7 Pass 3: this is money. What if discountPct is 110? What if items is empty? Close reading starts here.

Take away

  • Three passes: headline, shape, fine print.
  • Name each block with one word before you read its lines.
  • Spend your attention on the few lines that touch money, time, input or the outside world.

Quiz: test yourself

7 questions: a quick quiz, then a review drill. Pick an answer to see why it's right.