JavaScript Statements
A statement is one clear instruction for the computer.
Programs are made of many statements lined up like beads.
Think of each statement as one step on a treasure map.
What a statement is
Why we use semicolons
Blocks of statements
How order matters
One step at a time
JavaScript reads statements from top to bottom.
Each line tells it to do something.
If you change the order, the story can change.
Semicolons
A semicolon ; marks the end of a statement.
It is like a period at the end of a sentence.
JavaScript can often guess the end, but writing the semicolon keeps things clear.
Blocks with curly braces
Curly braces { } group statements together.
A group is called a block.
Think of a lunchbox. Many snacks live in one box.
Declarations are statements too
Making a variable is a statement.
Calling a function is a statement.
Printing with console.log is a statement.
Empty statements
A lonely semicolon is an empty statement.
It does nothing.
You usually do not need it on purpose.
Tip: Read your code out loud as steps. If one line does two big jobs, split it into smaller statements.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.