Clean β’ Professional
JavaScript statements are instructions that tell the computer what to do.
Think of them like steps in a recipeβeach statement performs a task, and together they make your program work.
JavaScript runs statements one by one from top to bottom, unless you control the flow with conditions or loops.
Letβs look at the most important types of statements every beginner should know.

Used to create variables that store data.
let age = 20; // can change later
const name = "Alex"; // constant value
var score = 100; // older way (avoid in modern code)
Assign or update values using =.
let count = 10;
count = 15;
console.log(count); // 15
Run an expression (calculation or function call).
let sum = 5 + 3;
console.log("Total:", sum);
alert("Hello!"); // function call as a statement
Make decisions using if, else if, else.
let age = 18;
if (age >= 18) {
console.log("You are an adult!");
} else {
console.log("You are a minor!");
}
Repeat tasks without writing code again and again.
// For loop
for (let i = 1; i <= 3; i++) {
console.log("Count:", i);
}
// While loop
let num = 1;
while (num <= 3) {
console.log("Num:", num);
num++;
}
Functions group code into reusable blocks.
function greet(name) {
console.log("Hello, " + name + "!");
}
greet("Sara"); // Hello, Sara!
Special statements to control loops and functions.
// Break & Continue
for (let i = 1; i <= 5; i++) {
if (i === 3) continue; // skip 3
if (i === 5) break; // stop loop
console.log(i);
}
// Return
function add(a, b) {
return a + b;
}
console.log(add(2, 3)); // 5Β