๐ฏ By the end of this lesson you canโฆ
- Recognise statements and where they end
- Write single-line and multi-line comments
- Use comments to explain and to switch code off
One instruction at a time
A statement is one complete instruction, like one sentence. JavaScript runs statements from top to bottom.
โก JavaScript
order.js
๐ Tap a line to explain it
1console.log("1. Wake up");2console.log("2. Brush teeth");3console.log("3. Eat breakfast");
Comments: notes for humans
โก JavaScript
comments.js
๐ Tap a line to explain it
1// This is a single-line comment. The computer skips it.2const tax = 0.18; // comments can also sit at the end of a line3 4/*5 This is a multi-line comment.6 Great for longer explanations.7*/8console.log(100 + 100 * tax);9// console.log("switched off");
๐ก Concept check
What does the computer do with
// total price ?๐ ๏ธ Uncomment to fix
The program should print Ready then Set then Go!, but one line has been commented out. Fix it.
๐ Key takeaways
- A statement is one instruction; it usually ends with
;. // commentand/* comment */are ignored by the computer.- Code runs from top to bottom, one statement at a time.
Finished reading & practising?
Saved in this browser. Create a free account to keep it forever.