🧩Code Block
Also known as Block of Code, Block (Programming), Compound Statement
A group of lines that run as one, like the body of a loop.
Think of it like
It is like a box of toys. You carry the whole box, not each toy one by one.
Example
In Emma's game, two lines sit in the if block. They run only when the player has no lives left.
Why it matters
Blocks decide which lines belong to which choice or loop. Get the edge of a block wrong and the wrong lines run.
Definition
Example code
javascript
if (lives === 0) {
showGameOver();
stopMusic();
}Common mistake
Key takeaways
- 1Runs together. Its lines act as one unit.
- 2Marked edges. Braces or pushed-in lines show it.
- 3Has its own scope. Names made inside may stay inside.