Step 1 of 10 · B · Naming a box, in code
Putting a value in a box, in code
Remember this scene from before?
Step 1 / 24recall
let score = 100;| Aspect | |||||
|---|---|---|---|---|---|
| Keyword to make a new box? | let | let | — | — | — |
| Type word in the line? | — | : number | — | int | — |
| Name needs a sign in front? | — | — | — | — | $ |
| Line ends with semicolon? | yes | yes | no | yes | yes |
We saw this — Howie drops a value into a named box.
In code, that whole picture becomes a single line.
Every line of this kind has the same three parts: a name, a value, and an = sign that drops the value into the box.
Some languages add a keyword in front to say "make a new box". Others skip the keyword.
Some languages also write a type word that locks the box to one family of value.
In
js, the keyword is let — let score = 100; says make a new box called score, drop 100 in.In
ts, the same line adds a type word after the name with a colon: let score: number = 100;.In
py, there is no keyword at all — score = 100 is enough. The first time the name appears, the box is made.In
dart, the type word comes first: int score = 100; reads as a number-box called score holding 100.In
php, the name itself starts with a $ sign — $score = 100; — every box-name in the language wears that mark.Some lines end with a
;, some do not. That is just punctuation — it does not change what the line means.Same idea — five different shapes. Pick any one, and you have made your first variable in code.
Check yourself
Quick check
Which of these means 'make a new box called total with the value 0' in JavaScript?
Match the pairs
Match each language to the **first word** that starts a new-box line:
