var a, b, c; // Statement 1 a = 5; // Statement 2 b = 4; // Statement 3 c = a + b; // Statement 4
The idea of the statement is the same in every programming language.
A computer program is a list of ‘ instructions’ to be ‘executed’ by a computer.
Computers follow these ‘ instructions ‘ or ‘ steps’.
Computers read these instructions from top to bottom, one by one.
It’s like doing something step by step.
But in a programming language, these programming instructions are called statements.
The idea of ‘statement’ is the same in every programming language.
But each programming language has its own syntax.
The syntax is a set of rules you have to follow when you write a computer program.
var x, y, z; // Create or Declare 3 variables x = 10; // Assign the value 10 to x y = 5; // Assign the value 5 to y z = x + y; // Assign the sum of x and y to z
For computers, it doesn’t matter if you put codes side by side they can read them.
But for us humans, it will be hard to read. Thus we use white space.
The following codes are equivalent.
var name = "Lia Sue"; // good practice var name="Lia Sue";
İt’s a good practice to put spaces around each operator ( = + – * / )