Plan before you code
An architect does not start stacking bricks. They draw the plan first — how many rooms, where the doors go, how the roof sits — and only then hand it to the builders. The drawing is cheap; moving a wall later is not.
Code works the same way. The plan is a few lines in plain words, and it costs you nothing to change before you write a single function.
Take this task: given a list of transactions, return the final balance. Each transaction carries a signed amount, so a deposit is positive and a withdrawal is negative. Skip the syntax for a moment and say the steps out loud:
Start the balance at zero. Walk the transactions in order. Add each transaction's signed amount. When the list ends, return the balance.
That is the whole solution, and you can check it by eye. Only now do you reach for code:
let balance = 0;
for (const transaction of transactions) {
balance = balance + transaction.amount;
}
return balance;
Writing the steps first forces out the decisions a blank editor hides: where the total starts, which direction each item moves it, and what happens when the list is empty. A plan you can read is a plan you can fix, long before it is buried in code.
You are about to answer a short quiz on planning before coding.