πŸ“
World 3 Β· Building Blocks

Notes to Yourself

Think about the notes you scribble in the margin of a recipe β€” β€œuse less sugar” or β€œthis takes longer than it says.” They help whoever reads it next, but they aren’t part of the recipe itself. In code, we have notes like that too β€” they’re called comments. πŸ“

What is a comment?

A comment is a note written just for humans. The computer skips right over it and never runs it. You make a comment by typing two slashes //. Everything after the slashes on that line is your note.

// This is a comment. The computer ignores it!
let lives = 3; // You can also add a note at the end of a line.
New word A comment is a note in your code for people to read. The computer pretends it isn't there.

Why write notes?

Code can be tricky to remember. A good comment explains why you did something, so that future-you (or a friend) understands it later. It’s like leaving sticky notes for yourself! πŸ—’οΈ

Look closely: the comments do not show up in the output! Only the println! line printed. The notes were just for us to read while writing the code. πŸŽ‰

Think of it like this… Comments are like the director's whispered notes during a play. The audience never hears them, but they help the actors know what to do. 🎭
Ferris says: Good comments explain the why, not the obvious. Instead of "add 1 to score," try "give a bonus point for finishing fast!" πŸ¦€
Try this! Add your own comment above the println! line that says // my favorite line. Press β–Ά Run β€” notice your note does NOT appear in the output!

Quick quiz

What happens to a line that starts with //?

Exactly! Comments are notes for humans, and the computer skips them. πŸ“

You learned… A comment starts with // and is a note for people, not the computer. Comments don't print and don't change what your program does β€” they just help you understand it. Next up: teaching your program to make choices! πŸ”€