Step 2 of 10 · B · Showing the value back
Showing it back, in code
output
(waiting…)
Remember when Howie peeked inside the box?
Step 1 / 23recall
let score = 100;
console.log(score);Output
100
| Aspect | |||||
|---|---|---|---|---|---|
| Word for "print"? | console.log | console.log | echo | ||
| Needs parentheses? | yes | yes | yes | yes | no |
| Line ends with semicolon? | yes | yes | no | yes | yes |
When Howie peeks into the box, only Howie sees the value.
To show it to anyone else — the screen, the user, the world — the program has to print it.
Printing means: read the box, then send the value out to the screen.
In
js and ts, the print line is console.log(score); — the box-name goes inside the parentheses.In
py, it is shorter: print(score). Same idea, fewer letters.In
dart, it is print(score); — like Python, but with the semicolon at the end.In
php, the word is echo — and echo does not need parentheses around the box-name.Most languages need parentheses around the name; PHP is the odd one out.
Most lines end with
;; Python is the odd one out.The name inside the parentheses is the box you want to read — the program looks it up, finds the value, and shows that.
Different words. *Same job*: read the box, send the value to the screen.
Check yourself
Quick check
In Python, which line shows the value of `score` on the screen?
