Javascript If…Else

Statements execute within the order they’re found in a very script. so as to form helpful programs, it’s sometimes necessary to use flow management, code that governs the “flow” of program execution. JavaScript supports conditionals like if-else statements that allow the selective execution of piece of code.

Example of Javascript If…Else

<!DOCTYPE html>
<html>
<head>
<title>java script Language</title>
<script>
var a=5;
var b=5
if(a==b)
{
alert(“The value of a and b is equal”);
}
else
{
alert(“the value are not equal”);
}

</script>
<body>
</body>
</html>

Result of Javascript If…Else :- The value of a and b is equal inside alert box.

Syntax :- 

if(expression) statements;

if(expression)   { statement;}   else {statement;}

if(expression)    { statement;}   else if (expression) statement…………;

if(expression)   { statement ; }  else if (expression) {statement; } else if(expression)    { statement;}    else {statement;}

 

 




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top