CONDITIONALS

If else conditionals

Conditionals are the expressions to evaluate either true or false , based on which it performs a specific task.

It helps to determine the program flow using if or else statements. JavaScript has several conditional statements, including if, else if, and else. For example:

app/page.tsx
1let x = 5;
2if (x > 10) {
3    console.log("x is greater than 10");
4} else if (x < 10) {
5    console.log("x is less than 10");
6} else {
7    console.log("x is equal to 10");
8}

The condition is a boolean expression that evaluates to either true or false. If the condition is true, the code in the "if" block is executed. If the condition is false, the code in the "else" block is executed (if present).