freecoding.school100% FREE · NO SIGNUP
Script SpringsISSUE #3 of 29

syntax · statements · expressions

SparkyVSNaN the Trickster
Sparky saysJS code is statements and expressions; semicolons end statements (usually optional but safer when explicit).

A statement does something (let x = 5;); an expression produces a value (5 + 3). JS auto-inserts semicolons, but a few edge cases bite, so many teams write them explicitly. Code is case-sensitive and whitespace between tokens is ignored.

Power-ups you unlock

NaN the Trickster attacks — common mistakes

Boss battleWrite a statement that stores an expression’s result, then log it.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>const sum = 5 + 3 * 2;   // expression assigned in a statement
document.getElementById('o').textContent = 'sum = ' + sum;</script></body></html>
▶ Open the interactive comic issue
‹ How To Add Js · Inline · Internal · ExternalComments · Single · Multi · Jsdoc ›