Conditional Statements in JavaScript | IF, IF-ELSE, ELSE-IF, Switch Statement in JavaScript



Conditional Statements in JavaScript | IF, IF-ELSE, ELSE-IF, Switch Statement in JavaScript

Conditional Statements in JavaScript |  IF, IF-ELSE, ELSE-IF, Switch Statement in JavaScript

In this video, we’ll be exploring the different conditional statements in JavaScript. We’ll be looking at the IF, IF-ELSE, ELSE-IF, and Switch statements.

By the end of this video, you’ll have a better understanding of how these statements work and be able to use them to make your code more readable and easy to understand.
#javascript #parnikatutorials #conditionalstatements #html #css #webdesigning

Conditional Statements
Very often when you write code, you want to perform different actions for different decisions.

You can use conditional statements in your code to do this.

In JavaScript we have the following conditional statements:

Use if to specify a block of code to be executed, if a specified condition is true
Use else to specify a block of code to be executed, if the same condition is false
Use else if to specify a new condition to test, if the first condition is false
Use switch to specify many alternative blocks of code to be executed

The if Statement
Use the if statement to specify a block of JavaScript code to be executed if a condition is true.

Syntax
if (condition) {
// block of code to be executed if the condition is true
}

The else Statement
Use the else statement to specify a block of code to be executed if the condition is false.

if (condition) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}

The else if Statement
Use the else if statement to specify a new condition if the first condition is false.

Syntax
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}

The switch statement is used to perform different actions based on different conditions.

Use the switch statement to select one of many code blocks to be executed.

Syntax
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
This is how it works:

The switch expression is evaluated once.
The value of the expression is compared with the values of each case.
If there is a match, the associated block of code is executed.
If there is no match, the default code block is executed.

Social media Links:
Instagram: https://www.instagram.com/parnikatutorials/
Website: http://parnikatutorials.in/
Email id: [email protected]
To get the regular updates:
Telegram link: https://t.me/Parnikatutorials
Facebook: https://m.facebook.com/profile.php?id=109245950811428&ref=content_filter
Linkedin: https://www.linkedin.com/in/parnika-tutorials-a8a9831b2/
Pinterest: https://in.pinterest.com/parnikatutorials0892/
Playlists:
Virtual Coffee with Jagadeesh:
https://youtube.com/playlist?list=PL4x0v29DZ2pArePUk30o6Twn7sqnqbYCH
Digital Logic Design:
https://youtube.com/playlist?list=PL4x0v29DZ2pA2ZmL3dclnA-HfHkFAy0GI
Computer Organization and Architecture:
https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pBRd8bChJJFtTn6ClJhKzfZ
C Programming:
https://www.youtube.com/watch?v=h9LtX_R-7uA&list=PL4x0v29DZ2pAIQdtRr-1zaYnqGiD_fU0M
Data Structures:
https://www.youtube.com/watch?v=m51BGPXdPAQ&list=PL4x0v29DZ2pCtKml6NNoBhYK4K_QnsCA_

Theory of Computation:
https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pDq-5SI9KlYxPDKdYCcmgJm

Compiler Design:
https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pBsF-lPUHQ_8uRy-LbDSHIH
Operating Systems: https://www.youtube.com/watch?v=vCCmq8hTC8Y&list=PL4x0v29DZ2pD6MzSQMIDSawLSKUZTFfxE

Databases: https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pCYEa9s3r5zWrFYIxGivlEC

Computer Networks:
https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pBBOq-QsHtCuA53IlRxIQNm
For GATE PYQs and much more explore:
https://www.youtube.com/c/ParnikaTutorials/playlists