</> Code Corner

JavaScript · JS Tutorial · Lesson 4

JS Statements

Instructions, semicolons and code blocks.

A JavaScript program is a list of programming statements. Statements are executed one by one, in the order they are written.

Example

<p id="demo"></p>
<script>
let x, y, z;   // Statement 1
x = 5;         // Statement 2
y = 6;         // Statement 3
z = x + y;     // Statement 4
document.getElementById("demo").innerHTML = "The value of z is " + z + ".";
</script>
  • Semicolons separate statements
  • JavaScript ignores extra white space
  • Statements can be grouped in code blocks inside curly brackets { }
  • Keywords like let, if, for, function and return identify actions

Keep reading “JS Statements”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋