Statement in a programming means any line of code that instructs the compiler to perform a specific task.
A computer program is a set of such statements. There can be multiple types of statements in a program code that controls the input and output of the actions that a program is designed for.
let x = 10; //Single line statement
if (x < 20) {
console.log("Hello");
console.log("Dear");
}
For multi line statement we use curly braces {} but these curly should be grouped with conditional statements or inside function.
In JavaScript, Semicolons are optional. Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java. JavaScript, however, allows you to omit this semicolon if each of your statements is placed on a separate line.
let val = 10 ; //whitespace here doesnt matter
let str = " Hello "; //Whitespace here will matter
let num = 1 0; // this is not valid
A code block in JavaScript is a section of code that is enclosed within curly braces "{ }". It is used to group one or more statements together and can be used to define the scope of a variable or function, or to create control structures such as loops and if-else statements. Code blocks are often used to organize and structure a program's logic.