Control Statements in JavaScript | Use of If Else in JavaScript - Skill Making

Skill Making

Always Increase Your Knowledge

Control Statements in JavaScript | Use of If Else in JavaScript

Control Statements in JavaScript | Use of If Else in JavaScript

Today in this article I will tell you a very useful topic of JavaScript. This is the initial starting of JavaScript which you must learn. Here you will get information about how to use control statements in JavaScript. Mostly here you will get that how you can use if else control statements in JavaScript.

Do you want to learn JavaScript?

Do you want to become a successful web developer?

How to use if else control statements in JavaScript?

If all these above questions having in your mind then you are at right place. Here you will get right information.

If you want to boost your JavaScript programming language than you should buy this book which is given below.

Control Statements in JavaScript

  • JavaScript offers almost the same control statements as we have in C language.
    • If, if else
    • Switch
    • While
    • Dowhile
    • For
    • For in

In this article you will learn if and if else statements. Here you will get that how to use if condition and how to use else condition?

Use of if and if else conditions in JavaScript

If(condition){

                                //code here

                                }

If(condition){

                                //code here

                                }

Else{

                //code here

                }

Example:

<!DOCTYPE html>

<html>

<head>

	<title>If Else Statements</title>

</head>

<body>

<script type="text/javascript">

	var x=7;

	if(x>0){

		document.write(x+" is a positive number.");

	}

	</script>

<br><br>

	<script type="text/javascript">
var y=-25;
	if(y>=0){

		document.write(y+" is a positive number.");

	}

	else{

		document.write(y+" is a negative number.");

	}

</script>




</body>

</html>

Output of if and if else control statements:

Leave a Reply

Your email address will not be published. Required fields are marked *

Skill Making © 2018 Frontier Theme