What are conditional statement in javascript?

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

There are multiple different types of conditionals statement

  • “if” statement
  • “if else ” statement
  • “if else if” statement

“if” statement

The if statement is the fundamental control statement that allows JavaScript to make decisions and execute statements conditionally.

synatx

if (expression)
 {
   Statement
}

“if else” statement

The ‘if…else’ statement is the next form of control statement that allows JavaScript to execute statements in a more controlled way.

syntax

if (expression) 
{
   Statement
} else 
{
   Statement
}

“if else if “statement

The if…else if… statement is an advanced form of if…else that allows JavaScript to make a correct decision out of several conditions.

syntax

if (expression 1) 
{
   Statement
} else if (expression 2) 
{
   Statement
} else if (expression 3) 
{
   Statement
} else 
{
   Statement
}

example

<!DOCTYPE html>
<html>
<head>
<title>javascript</title>
</head>
<body>
<script>
		var a=200;
		var b=300;
		
		if(a<b)
		{
		document.write("a is less than b");
		}
		else if(a>b)
		{
		document.write("a is greater than b");
		}
		else if(a==b)
		{
		document.write("a is equal to  b");
		}
		else
		{
		document.write("wrong value");
		}
</script>
</body>
</html>

output

a is less than b

Related Posts

PR Points Calculator : The Ultimate Guide to Immigration Eligibility Around the World

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

The Complete Guide to Certified FinOps Professional: Career Path, ROI, and Technical Mastery

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Certified FinOps Manager: The Complete Guide to Mastering Cloud Value and Career Growth

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Certified FinOps Engineer Career Path for Engineers and Managers

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Certified FinOps Architect: Strategic Cloud Optimization and Financial Governance

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Mastering Data Pipelines: The Complete Career Guide to CDOM – Certified DataOps Manager

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x