Minds
It is Recommended to practice while you learn

IF & ELSE statement

The if...else statement executes a statement if a specified condition is truthy. If the condition is falsy, another statement in the optional else clause will be executed.

Syntax :-

if (condition)

statement1

// With an else clause

if (condition)

statement1

else

statement2

}

console.log("Completed");

else-if statement

Multiple if...else statements can be nested to create an else if clause. Note that there is no elseif (in one word) keyword in JavaScript.

Syntax :-

if (condition 1)

statement1

else if (condition 2)

statement2

else if (condition 3)

statement3

else

statement4

}

console.log("Completed");

switch statement

The switch statement evaluates an expression, matching the expression's value against a series of case clauses, and executes statements after the first case clause with a matching value, until a break statement is encountered. The default clause of a switch statement will be jumped to if no case matches the expression's value.

Syntax :-

const = 'Papayas';

case 'Oranges':

console.log('Oranges are $0.59 a pound.');

break;

case 'mangoes':

case 'pappayas':

console.log('Mangoes and papayas are $2.79 a pound.');

// Expected output: "Mangoes and papayas are $2.79 a pound."

break;

deafault:

console.log('not found');